<?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>环境 &#8211; chang的个人博客</title>
	<atom:link href="https://www.qiqin-chang.cn/category/front/%e7%8e%af%e5%a2%83/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.qiqin-chang.cn</link>
	<description></description>
	<lastBuildDate>Sun, 28 Dec 2025 19:27:10 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.qiqin-chang.cn/wp-content/uploads/2025/04/cropped-无背景-圆形-32x32.png</url>
	<title>环境 &#8211; chang的个人博客</title>
	<link>https://www.qiqin-chang.cn</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>node.js</title>
		<link>https://www.qiqin-chang.cn/node-js/</link>
					<comments>https://www.qiqin-chang.cn/node-js/#respond</comments>
		
		<dc:creator><![CDATA[乐章]]></dc:creator>
		<pubDate>Mon, 11 Aug 2025 05:20:22 +0000</pubDate>
				<category><![CDATA[前端]]></category>
		<category><![CDATA[环境]]></category>
		<guid isPermaLink="false">http://www.qiqin-chang.cn/?p=529</guid>

					<description><![CDATA[nvm 下载安装： 说明：nvm（node version manager）node.js版本管理器 http [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h1 class="wp-block-heading">nvm 下载安装：</h1>



<p>说明：nvm（node version manager）node.js版本管理器</p>



<p><a href="https://github.com/coreybutler/nvm-windows/releases">https://github.com/coreybutler/nvm-windows/releases</a></p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="526" src="https://www.qiqin-chang.cn/wp-content/uploads/2025/08/nvm-1-1024x526.png" alt="" class="wp-image-530" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2025/08/nvm-1-1024x526.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2025/08/nvm-1-300x154.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2025/08/nvm-1-768x394.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2025/08/nvm-1.png 1136w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>安装注意事项：</p>



<ol class="wp-block-list">
<li>要卸载掉现有的 nodejs</li>



<li>提示选择 nvm 和 nodejs 目录时，一定要避免目录中出现空格</li>



<li>选用【以管理员身份运行】cmd 程序来执行 nvm 命令</li>



<li>首次运行前设置好国内镜像地址</li>
</ol>



<pre class="wp-block-preformatted">nvm node_mirror https://npmmirror.com/mirrors/node/<br>nvm npm_mirror https://npmmirror.com/mirrors/npm/</pre>



<p>查看可用版本</p>



<pre class="wp-block-preformatted">nvm list available</pre>



<p>安装nvm:建议 安装LTS版（长期支持版）</p>



<pre class="wp-block-preformatted">nvm install 版本号</pre>



<p>查询已安装版本：</p>



<pre class="wp-block-preformatted">nvm list</pre>



<p>切换版本：</p>



<pre class="wp-block-preformatted">nvm use 版本号</pre>



<p>安装后 nvm 自己的环境变量会自动添加，但可能需要添加 nodejs 的 PATH 环境变量</p>



<figure class="wp-block-image size-full"><img decoding="async" width="839" height="217" src="https://www.qiqin-chang.cn/wp-content/uploads/2025/08/node.js-2.png" alt="" class="wp-image-531" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2025/08/node.js-2.png 839w, https://www.qiqin-chang.cn/wp-content/uploads/2025/08/node.js-2-300x78.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2025/08/node.js-2-768x199.png 768w" sizes="(max-width: 839px) 100vw, 839px" /></figure>



<p>系统环境变量：</p>



<figure class="wp-block-image size-full"><img decoding="async" width="480" height="75" src="https://www.qiqin-chang.cn/wp-content/uploads/2025/08/node.js-3.png" alt="" class="wp-image-532" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2025/08/node.js-3.png 480w, https://www.qiqin-chang.cn/wp-content/uploads/2025/08/node.js-3-300x47.png 300w" sizes="(max-width: 480px) 100vw, 480px" /></figure>



<h1 class="wp-block-heading">Node 下载安装：(不推荐)</h1>



<p>官方网站：<a href="https://nodejs.org/zh-cn">https://nodejs.org/zh-cn</a></p>



<p>下载安装：<a href="https://nodejs.org/zh-cn/download">https://nodejs.org/zh-cn/download</a></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="526" src="https://www.qiqin-chang.cn/wp-content/uploads/2025/08/node.js-1-1024x526.png" alt="" class="wp-image-533" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2025/08/node.js-1-1024x526.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2025/08/node.js-1-300x154.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2025/08/node.js-1-768x394.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2025/08/node.js-1.png 1136w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h1 class="wp-block-heading">NPM(包管理器):</h1>



<p>说明：node.js自带NPM包管理工具</p>



<h2 class="wp-block-heading">检查 npm：</h2>



<p>npm 是 js 的包管理器，就类似于 java 界的 maven，要确保它使用的是国内镜像</p>



<p>检查镜像</p>



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



<p>如果返回的不是 <code>https://registry.npm.taobao.org/</code>，需要做如下设置</p>



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



<h2 class="wp-block-heading">搭建前端服务器:</h2>



<p>新建一个保存项目的 client 文件夹，进入文件夹执行</p>



<pre class="wp-block-preformatted">npm install express --save-dev</pre>



<p>修改 package.json 文件</p>



<pre class="wp-block-code"><code>{
  "type": "module",
  "devDependencies": {
    "express": "^4.18.1"
  }
}</code></pre>



<ul class="wp-block-list">
<li>其中 devDependencies 是 npm install &#8211;save-dev 添加的</li>
</ul>



<p>编写 main.js 代码：</p>



<pre class="wp-block-code"><code>import express from 'express'
const app = express()
​
app.use(express.static('./'))
app.listen(7070)</code></pre>



<p>呼出终端：</p>



<pre class="wp-block-preformatted">ctrl+shift+`</pre>



<p>执行 js 代码（运行前端服务器）：</p>



<pre class="wp-block-preformatted">node main.js</pre>



<p>中断前端服务器：</p>



<pre class="wp-block-preformatted">ctrl+c</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://www.qiqin-chang.cn/node-js/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
