nodeJS设置淘宝镜像

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/

2.3 查看Nodejs默认配置

 
  1. #npm config ls -l

  2. ; cli configs

  3. long = true

  4. user-agent = "npm/2.14.12 node/v4.2.4 win32 x64"

  5.  
  6. ; builtin config undefined

  7. prefix = "C:\\Users\\zgr\\AppData\\Roaming\\npm"

  8. registry = "https://registry.npm.taobao.org/"

  9.  
  10. ; default values

  11. access = null

  12. always-auth = false

  13. bin-links = true

  14. browser = null

  15. ca = null

  16. cache = "C:\\Users\\zgr\\AppData\\Roaming\\npm-cache"

  17. cache-lock-retries = 10

  18. cache-lock-stale = 60000

  19. cache-lock-wait = 10000

  20. cache-max = null

  21. cache-min = 10

  22. cafile = undefined

  23. cert = null

  24. color = true

  25. depth = null

  26. description = true

  27. dev = false

  28. editor = "notepad.exe"

  29. engine-strict = false

  30. fetch-retries = 2

  31. fetch-retry-factor = 10

  32. fetch-retry-maxtimeout = 60000

  33. fetch-retry-mintimeout = 10000

  34. force = false

  35. git = "git"

  36. git-tag-version = true

  37. global = false

  38. globalconfig = "C:\\Users\\zgr\\AppData\\Roaming\\npm\\etc\\npmrc"

  39. globalignorefile = "C:\\Users\\zgr\\AppData\\Roaming\\npm\\etc\\npmignore"

  40. group = 0

  41. heading = "npm"

  42. https-proxy = null

  43. if-present = false

  44. ignore-scripts = false

  45. init-author-email = ""

  46. init-author-name = ""

  47. init-author-url = ""

  48. init-license = "ISC"

  49. init-module = "C:\\Users\\zgr\\.npm-init.js"

  50. init-version = "1.0.0"

  51. json = false

  52. key = null

  53. link = false

  54. local-address = undefined

  55. loglevel = "warn"

  56. ; long = false (overridden)

  57. message = "%s"

  58. node-version = "4.2.4"

  59. npat = false

  60. onload-script = null

  61. optional = true

  62. parseable = false

  63. ; prefix = "C:\\Program Files\\nodejs" (overridden)

  64. production = false

  65. proprietary-attribs = true

  66. proxy = null

  67. rebuild-bundle = true

  68. ; registry = "https://registry.npmjs.org/" (overridden)

  69. rollback = true

  70. save = false

  71. save-bundle = false

  72. save-dev = false

  73. save-exact = false

  74. save-optional = false

  75. save-prefix = "^"

  76. scope = ""

  77. searchexclude = null

  78. searchopts = ""

  79. searchsort = "name"

  80. shell = "C:\\Windows\\system32\\cmd.exe"

  81. shrinkwrap = true

  82. sign-git-tag = false

  83. spin = true

  84. strict-ssl = true

  85. tag = "latest"

  86. tag-version-prefix = "v"

  87. tmp = "C:\\Users\\zgr\\AppData\\Local\\Temp"

  88. umask = 0

  89. unicode = true

  90. unsafe-perm = true

  91. usage = false

  92. user = 0

  93. ; user-agent = "npm/{npm-version} node/{node-version} {platform} {arch}" (overri

  94. dden)

  95. userconfig = "C:\\Users\\zgr\\.npmrc"

  96. version = false

  97. versions = false

  98. viewer = "browser"

2.4 设置全局安装目录
npm config set cache "D:\nodejs\node_cache"
npm config set prefix "D:\nodejs\node_global"

然后就可以愉快的使用cnpm安装工具了

3 常用命令集合

 
  1. node -v #查看安装版本

  2. npm -v #查看npm安装版本

  3.  
  4. npm config ls -l #查看配置项

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值