新安装NODEJS之后配置

1配置阿里镜像服务器

npm config set registry https://registry.npm.taobao.org --global

npm config set disturl https://npm.taobao.org/dist --global

  

 npm config set registry  https://registry.npmmirror.com --global

 

 npm config set registry  https://registry.npmmirror.com  --location=global

2安装cnpm

npm install cnpm -g -registry=https://registry.npm.taobao.org 

npm install cnpm -g -registry=https://registry.npmmirror.com 

3安装yarn

npm install -g yarn


4配置yarn阿里镜像

yarn config set registry https://registry.npm.taobao.org

yarn config set registry https://registry.npmmirror.com 

5修改全局安装路径

yarn config  set global-folder "你的磁盘路径"

6修改yarn缓存路径

yarn config set cache-folder "你的磁盘路径"

7 升级Nodejs版本

安装管理工具
npm install -g n

 

  安装最新版

  n latest

 

安装指定版本

$ n8.11.3

2.3 切换nodejs版本

$ n

选择已安装的版本

οnode/8.11.3node/10.4.1

查看当前版本node -v,下面表示已切换成功

v8.13.3

但问题来了,切换后,查看版本还是原来的v6.13.3,看下面 使用n切换nodejs版本失效的解决办法

3 切换失效的解决办法

3.1 查看 node 当前安装路径

$ whichnode/usr/local/bin/node#举个例子

3.2 而 n 默认安装路径是 /usr/local,若你的 node 不是在此路径下,n 切换版本就不能把bin、lib、include、share 复制该路径中,所以我们必须通过N_PREFIX变量来修改 n 的默认node安装路径。

编辑环境配置文件:

$ vim ~/.bash_profile

3.3 将下面两行代码插入到文件末尾:

exportN_PREFIX=/usr/local#node实际安装位置exportPATH=$N_PREFIX/bin:$PATH

3.4 :wq保存退出

3.5 执行source使修改生效。

$ source ~/.bash_profile

3.6 这时候再查看node -v发现版本切换成功了。 

 

electron_mirror 
npm config set electron_mirror "https://npmmirror.com/mirrors/electron/"

npm config set electron_builder_binaries_mirror "https://mirrors.huaweicloud.com/electron-builder-binaries/"

 

 


 
参考:https://www.jianshu.com/p/2da3e3c6b8ac
 

 




 

 

 

 

 

 

 





 

posted @ 2019-09-25 09:56  leechg  阅读(392)  评论(0编辑  收藏  举报