<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Node.js &#8211; wqh博客</title>
	<atom:link href="https://wangqianhong.com/tag/node-js/feed/" rel="self" type="application/rss+xml" />
	<link>https://wangqianhong.com</link>
	<description>和而不同</description>
	<lastBuildDate>Wed, 22 May 2024 01:28:54 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://wangqianhong.com/wp-content/uploads/2020/09/cropped-1-1-1-32x32.png</url>
	<title>Node.js &#8211; wqh博客</title>
	<link>https://wangqianhong.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Centos安装TypeScript环境</title>
		<link>https://wangqianhong.com/2022/01/centos%e5%ae%89%e8%a3%85typescript%e7%8e%af%e5%a2%83/</link>
					<comments>https://wangqianhong.com/2022/01/centos%e5%ae%89%e8%a3%85typescript%e7%8e%af%e5%a2%83/#respond</comments>
		
		<dc:creator><![CDATA[wqh_work]]></dc:creator>
		<pubDate>Sat, 15 Jan 2022 02:26:00 +0000</pubDate>
				<category><![CDATA[技术文章]]></category>
		<category><![CDATA[Centos]]></category>
		<category><![CDATA[Node.js]]></category>
		<guid isPermaLink="false">https://wangqianhong.com/?p=2733</guid>

					<description><![CDATA[<p>在安装TypeScript之前，需要先安装NodeJs，可以参考下面的网站进行安装 接下来使用npm&#8230; <a href="https://wangqianhong.com/2022/01/centos%e5%ae%89%e8%a3%85typescript%e7%8e%af%e5%a2%83/" class="more-link read-more" rel="bookmark">继续阅读 <span class="screen-reader-text">Centos安装TypeScript环境</span><i class="fa fa-arrow-right"></i></a></p>
<p><a rel="nofollow" href="https://wangqianhong.com/2022/01/centos%e5%ae%89%e8%a3%85typescript%e7%8e%af%e5%a2%83/">Centos安装TypeScript环境</a>最先出现在<a rel="nofollow" href="https://wangqianhong.com">wqh博客</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<p>在安装TypeScript之前，需要先安装NodeJs，可以参考下面的网站进行安装</p>



<figure class="wp-block-embed-wordpress wp-block-embed is-type-wp-embed is-provider-wqh博客"><div class="wp-block-embed__wrapper">
<blockquote class="wp-embedded-content" data-secret="MHweV80YWI"><a href="https://wangqianhong.com/2022/01/centos%e5%ae%89%e8%a3%85nodejs%e7%a8%b3%e5%ae%9a%e7%89%88lts/">Centos安装nodejs稳定版(LTS)</a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" title="《Centos安装nodejs稳定版(LTS)》—wqh博客" src="https://wangqianhong.com/2022/01/centos%e5%ae%89%e8%a3%85nodejs%e7%a8%b3%e5%ae%9a%e7%89%88lts/embed/#?secret=MHweV80YWI" data-secret="MHweV80YWI" width="500" height="282" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
</div></figure>



<p>接下来使用npm安装</p>



<pre class="wp-block-preformatted"><code>npm install -g typescript</code>

added 1 package, and audited 2 packages in 10s
found <strong>0</strong> vulnerabilities</pre>



<p>使用下面命令验证是否安装成功</p>



<pre class="wp-block-preformatted"><code>tsc --version</code>

Version 5.0.4

<code>tsc --help</code>

tsc: The TypeScript Compiler - Version 5.0.4
TS
<strong>COMMON COMMANDS</strong>

tsc
Compiles the current project (tsconfig.json in the working directory.)

tsc app.ts util.ts
Ignoring tsconfig.json, compiles the specified files with default compiler options.

tsc -b
Build a composite project in the working directory.

tsc --init
Creates a tsconfig.json with the recommended settings in the working directory.

tsc -p ./path/to/tsconfig.json
Compiles the TypeScript project located at the specified path.

tsc --help --all
An expanded version of this information, showing all possible compiler options

tsc --noEmit
tsc --target esnext
Compiles the current project, with additional settings.

<strong>COMMAND LINE FLAGS</strong>

--help, -h Print this message.

--watch, -w Watch input files.

--all Show all compiler options.

--version, -v Print the compiler's version.

--init Initializes a TypeScript project and creates a tsconfig.json file.

--project, -p Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'.

--build, -b Build one or more projects and their dependencies, if out of date

--showConfig Print the final configuration instead of building.

<strong>COMMON COMPILER OPTIONS</strong>

--pretty Enable color and formatting in TypeScript's output to make compiler errors easier to read.
type: boolean
default: true

--declaration, -d Generate .d.ts files from TypeScript and JavaScript files in your project.
type: boolean
default: `false`, unless `composite` is set

--declarationMap Create sourcemaps for d.ts files.
type: boolean
default: false

--emitDeclarationOnly Only output d.ts files and not JavaScript files.
type: boolean
default: false

--sourceMap Create source map files for emitted JavaScript files.
type: boolean
default: false

--target, -t Set the JavaScript language version for emitted JavaScript and include compatible library declarations.
one of: es3, es5, es6/es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext
default: es5

--module, -m Specify what module code is generated.
one of: none, commonjs, amd, umd, system, es6/es2015, es2020, es2022, esnext, node16, nodenext
default: undefined

--lib Specify a set of bundled library declaration files that describe the target runtime environment.
one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, esnext, dom, dom.iterable, webworker, webworker.importscript
s, webworker.iterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflec
t, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarra
ys, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es
2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.stri
ng, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise/esnext.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl
, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.sharedmemory, es2022.string/esnext.string, es2022.regexp, es2023.array/esnext.ar
ray, esnext.intl, decorators, decorators.legacy
default: undefined

--allowJs Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files.
type: boolean
default: false

--checkJs Enable error reporting in type-checked JavaScript files.
type: boolean
default: false

--jsx Specify what JSX code is generated.
one of: preserve, react, react-native, react-jsx, react-jsxdev
default: undefined

--outFile Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output.

--outDir Specify an output folder for all emitted files.

--removeComments Disable emitting comments.
type: boolean
default: false

--noEmit Disable emitting files from a compilation.
type: boolean
default: false

--strict Enable all strict type-checking options.
type: boolean
default: false

--types Specify type package names to be included without being referenced in a source file.

--esModuleInterop Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility.
type: boolean
default: false

You can learn about all of the compiler options at https://aka.ms/tsc</pre>



<p></p>
<p><a rel="nofollow" href="https://wangqianhong.com/2022/01/centos%e5%ae%89%e8%a3%85typescript%e7%8e%af%e5%a2%83/">Centos安装TypeScript环境</a>最先出现在<a rel="nofollow" href="https://wangqianhong.com">wqh博客</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://wangqianhong.com/2022/01/centos%e5%ae%89%e8%a3%85typescript%e7%8e%af%e5%a2%83/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Centos安装nodejs稳定版(LTS)</title>
		<link>https://wangqianhong.com/2022/01/centos%e5%ae%89%e8%a3%85nodejs%e7%a8%b3%e5%ae%9a%e7%89%88lts/</link>
					<comments>https://wangqianhong.com/2022/01/centos%e5%ae%89%e8%a3%85nodejs%e7%a8%b3%e5%ae%9a%e7%89%88lts/#comments</comments>
		
		<dc:creator><![CDATA[wqh_work]]></dc:creator>
		<pubDate>Fri, 07 Jan 2022 02:13:00 +0000</pubDate>
				<category><![CDATA[技术文章]]></category>
		<category><![CDATA[Centos]]></category>
		<category><![CDATA[Node.js]]></category>
		<guid isPermaLink="false">https://wangqianhong.com/?p=2731</guid>

					<description><![CDATA[<p>查看可用的nodejs dnf module list nodejs CentOS Linux 8 &#8230; <a href="https://wangqianhong.com/2022/01/centos%e5%ae%89%e8%a3%85nodejs%e7%a8%b3%e5%ae%9a%e7%89%88lts/" class="more-link read-more" rel="bookmark">继续阅读 <span class="screen-reader-text">Centos安装nodejs稳定版(LTS)</span><i class="fa fa-arrow-right"></i></a></p>
<p><a rel="nofollow" href="https://wangqianhong.com/2022/01/centos%e5%ae%89%e8%a3%85nodejs%e7%a8%b3%e5%ae%9a%e7%89%88lts/">Centos安装nodejs稳定版(LTS)</a>最先出现在<a rel="nofollow" href="https://wangqianhong.com">wqh博客</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<h3>查看可用的nodejs</h3>



<pre class="wp-block-preformatted"><code>dnf module list nodejs</code>

<strong>CentOS Linux 8 - AppStream</strong>
Name Stream Profiles Summary
nodejs 10 [d] common [d], development, minimal, s2i Javascript runtime
nodejs 12 common [d], development, minimal, s2i Javascript runtime
nodejs 14 common [d], development, minimal, s2i Javascript runtime
nodejs 16 common [d], development, minimal, s2i Javascript runtime

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled</pre>



<p>可以看到一个有4个版本，分别是10、12、14和16，这里选择切换到最新的16版本</p>



<pre class="wp-block-code"><code>dnf module enable nodejs:16</code></pre>



<h3>命令安装</h3>



<p>切换到16版本，然后使用下面命令安装即可：</p>



<pre class="wp-block-code"><code>dnf install nodejs</code></pre>



<p>等待安装完成之后 ，使用下面命令验证安装是否成功：</p>



<pre class="wp-block-preformatted"><code>node --version</code>
v16.13.1</pre>



<p>如果想安装其他版本，可以使用下面命令进行安装</p>



<pre class="wp-block-code"><code>curl -fsSL https://rpm.nodesource.com/setup_18.x | bash -</code></pre>



<p>等repo更新完成，直接安装即可</p>



<pre class="wp-block-code"><code>yum install nodejs</code></pre>



<h3>修改国内镜像</h3>



<pre class="wp-block-code"><code>npm config set registry https://registry.npmmirror.com</code></pre>



<p>验证命令</p>



<pre class="wp-block-code"><code>npm config get registry</code></pre>



<p>如果返回https://registry.npmmirror.com，说明镜像配置成功。</p>



<h3>安装yarn</h3>



<p>Yarn 是为了弥补 npm 的一些缺陷而出现的：</p>



<p>npm 安装包（packages）的速度不够快，拉取的 packages 可能版本不同</p>



<p>npm 允许在安装 packages 时执行代码，这就埋下了安全隐患</p>



<pre class="wp-block-code"><code>npm install --global yarn</code></pre>



<h3>卸载nodejs</h3>



<pre class="wp-block-code"><code>yum remove nodejs &amp;&amp; rm -r /etc/yum.repos.d/nodesource*.repo &amp;&amp; yum clean all</code></pre>
<p><a rel="nofollow" href="https://wangqianhong.com/2022/01/centos%e5%ae%89%e8%a3%85nodejs%e7%a8%b3%e5%ae%9a%e7%89%88lts/">Centos安装nodejs稳定版(LTS)</a>最先出现在<a rel="nofollow" href="https://wangqianhong.com">wqh博客</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://wangqianhong.com/2022/01/centos%e5%ae%89%e8%a3%85nodejs%e7%a8%b3%e5%ae%9a%e7%89%88lts/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
