nodejs环境配置

nodejs环境配置

1.系统环境变量

NODE_PATH=C:\nodejs\node_global\node_modules
// Path系统环境变量追加以下内容
Path = ;C:\Program Files\nodejs;C:\nodejs\node_global

C:\Program Files\nodejs node命令位置;
C:\nodejs\node_global node安装的第三方命令(如:cnpm、webpack、vue)位置;

2.配置

npm config set prefix "C:\nodejs\node_global"
npm config set cache "C:\nodejs\node_cache"
npm config set registry=http://registry.npm.taobao.org
npm config ls
npm install -g cnpm
npm install -g yarn
yarn -v
yarn config set registry http://registry.npm.taobao.org
yarn config list
npm install -g cnpm
cnpm -v
npm install @vue/cli -g
vue -V
cnpm install node-sass --save
node-sass -v
  • 改回官方配置
npm config set registry https://registry.npmjs.org
yarn config set registry https://registry.yarnpkg.com

3.使用nrm管理源

npm install-g nrm
nrm ls
nrm test taobao
nrm use taobao

4.使用nvm切换nodejs版本

nvm-windows下载地址

切换node版本时,推荐使用“以管理身份运行”
原理:移除系统环境变量中nodejs路径,创建NVM_SYMLINK环境变量指向nvm use指定版本的软链接(快捷方式)上。

nvm -v
nvm ls
nvm install latest
nvm install lts
nvm current
nvm use lts
nvm current
nvm use 16.13.0
nvm current

10.问题

(1) node-gpy rebuild失败
  • 问题描述

执行npm install时提示node-gpy rebuild失败

  • 解决办法

下载最新版本Node.js安装包并安装,勾选Tools for Native Modules页的复选框,自动安装PythonVisual Studio Build Tools(推荐自动安装,避免Python或Visual Studio Build Tools版本不匹配问题)

在这里插入图片描述

(2) node-sass从github下载不了
npm i node-sass --sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
  • .npmrc
phantomjs_cdnurl=http://cnpmjs.org/downloads
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
registry=https://registry.npm.taobao.org

另外注意node-sass和nodejs版本依赖关系

参考:
webstorm 设置 npm 环境
使用nrm切换npm源
整理 node-sass 安装失败的原因及解决办法
node和node-sass版本问题

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

搬山境KL攻城狮

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值