nodeJS安装及npm设置淘宝镜像

nodeJS安装及npm设置淘宝镜像

  •     node.js安装
  •     下载node.js安装包:https://nodejs.org/en/download/,下载相应版本的node.js.
  •     需注意,在window中,node的安装目录中,最好不要有空格或中文字符。
  •     nodeJS的资源仓库在国内使用过程中,偶尔会遇到各种资源问题,通常设置为淘宝的镜像,网上很多说法是安装淘宝镜像,即
    $ npm install -g cnpm --registry=https://registry.npm.taobao.org
    然后再用到npm install的时候,使用cnpm install进行安装node_modules。
    但是该种方式,在集成到IED的时候,你如在IDEA中,如果想在IDEA中,直接使用node的命令,进行install,就行不通了。
    这个时候,可以使用第二种方式:
    npm config set registry " https://registry.npm.taobao.org "
    更改npm的config的registry 为淘宝镜像,然后再使用npm的时候,就是从淘宝镜像拉取数据了。

    在更新node-sass中,有时候也会出现资源下载不了的问题,通常是git上的资源下载不了,这时候,可以更改node-sass的资源路径为淘宝的
    npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
    phantomjs的源
    npm config set phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/
    electron源
    npm config set electron_mirror=https://npm.taobao.org/mirrors/electron/
原文地址:https://www.cnblogs.com/zhouyun-yx/p/10930700.html