windows node安装

2019-06-10  本文已影响0人  依圻

2、在键盘按下【win+R】键,输入cmd,回车,然后输入下面的命令:
npm config set prefix "D:\Program Files\nodejs\node_global"
npm config set cache "D:\Program Files\nodejs\node_cache"
或者
在nodejs的安装目录中找到node_modules\npm.npmrc文件,修改如下:
prefix = D:\Program Files\nodejs\node_global
cache = D:\Program Files\nodejs\node_cache


npmrc.png

如果这时你输入npm install express -g进行全局安装,你会发现在你自定义的node_global目录下出现了express


express.png

但是如果你现在开始用require('express'),还是会报错,因为系统现在还在使用原来的默认路径。所以还需要修改系统环境变量,告诉系统新的路径


ex.png
上一篇 下一篇

猜你喜欢

热点阅读