Node.js 安装与设置
一、nodejs 安装
建议安装 LTS 版本
二、设置
查看 nodejs 默认 npm registry
npm config get registry
设置 npm registry 为国内源
npm config set registry https://registry.npmmirror.com
在 ~/.npmrc 加入下面内容,可以避免安装 node-sass 失败
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
.npmrc 文件位于
win:C:\Users[你的账户名称].npmrc
linux:直接使用 vi ~/.npmrc
三、升级项目常用 npm 包版本
当需要升级项目所需包的版本时,可以:
npm update
四、建议将 Node.js 升级到最新的稳定版本(可选)
使用 nvm 安装最新稳定版 Node.js
nvm install stable
五、常用操作
(一)查询库版本
npm info npm versions
(二)npm 升级
查看 npm 当前版本
npm -v
如果不是最新版本,运行指令
npm install -g npm
如果想更新到指定版本,运行指令
npm -g install npm@7.10.0
六、安装 Vue 开发环境
npm install -g @vue/cli