國內(nèi)優(yōu)秀npm鏡像:
淘寶npm鏡像
搜索地址:http://npm.taobao.org/
registry地址:http://registry.npm.taobao.org/
cnpmjs鏡像
搜索地址:http://cnpmjs.org/
registry地址:http://r.cnpmjs.org/
鏡像舉例:
1.臨時(shí)使用: 在命令行中臨時(shí)指定registry:
$ npm install <module> --registry http://npm_registry
舉例:
$ npm --registry https://registry.npm.taobao.org install express
2.持久使用:
通過 npm config set 命令修改registry, 或者修改npmrc 文件(比如: ~/.npmrc)
舉例:
npm修改為淘寶源
$ npm config set registry https://registry.npm.taobao.org
配置后可通過下面方式來驗(yàn)證是否成功
npm info express
//npm切換為官方源
$ npm config set registry https://registry.npmjs.org
3.通過cnpm
使用
$ npm install -g cnpm --registry=https://registry.npm.taobao.org
使用cnpm install expresstall express
建議使用 cnpm:
$ npm install -g cnpm --registry=https://registry.npm.taobao.org
舉例:
? jia_vue-element-admin git:(master) ? npm install -g cnpm --registry=https://registry.npm.taobao.org
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
/usr/local/bin/cnpm -> /usr/local/lib/node_modules/cnpm/bin/cnpm
+ cnpm@6.1.1
added 419 packages from 231 contributors, removed 326 packages, updated 131 packages and moved 5 packages in 18.599s
$ cnpm install
? [22/47] Installing stream-browserify@^2.0.1[npminstall:get] retry GET http://registry.npm.taobao.org/extglob/download/extglob-0.3.2.tgz after 100ms, retry left 4, error: ResponseError: socket hang up (req "error"), GET http://registry.npm.taobao.org/extglob/download/extglob-0.3.2.tgz -1 (connected: true, keepalive socket: true, agent status: {"createSocketCount":13,"createSocketErrorCount":0,"closeSocketCount":3,"errorSocketCount":0,"timeoutSocketCount":0,"requestCount":699,"freeSockets":{},"sockets":{"registry.npm.taobao.org:80:":10},"requests":{"registry.npm.taobao.org:80:":32}})
headers: {}
? [22/47] Installing requires-port@1.x.x[npminstall:get] retry GET http://registry.npm.taobao.org/util-deprecate after 100ms, retry left 4, error: ResponseError: socket hang up (req "error"), GET http://registry.npm.taobao.org/util-deprecate -1 (connected: true, keepalive socket: true, agent status: {"createSocketCount":14,"createSocketErrorCount":0,"closeSocketCount":4,"errorSocketCount":0,"timeoutSocketCount":0,"requestCount":725,"freeSockets":{},"sockets":{"registry.npm.taobao.org:80:":10},"requests":{"registry.npm.taobao.org:80:":29}})
headers: {}
? [44/47] Installing hoek@2.x.xplatform unsupported babel-loader@7.1.2 ? webpack@2.7.0 ? watchpack@1.4.0 ? chokidar@1.7.0 ? fsevents@^1.0.0 Package require os(darwin) not compatible with your platform(linux)
[fsevents@^1.0.0] optional install error: Package require os(darwin) not compatible with your platform(linux)
? Installed 47 packages
? Linked 570 latest versions
? Run 0 scripts
peerDependencies link ajv@4.11.8 in /opt/uop-frontend/node_modules/_ajv-keywords@1.5.1@ajv-keywords unmet with /opt/uop-frontend/node_modules/ajv(5.2.2)
Recently updated (since 2017-08-22): 9 packages (detail see file /opt/uop-frontend/node_modules/.recently_updates.txt)
? All packages installed (666 packages installed from npm registry, used 1m, speed 344.94kB/s, json 617(7.53MB), tarball 20.59MB)
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px 'Lucida Grande'; color: #3597fc}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px 'Lucida Grande'}span.s1 {color: #000000}span.s2 {text-decoration: underline}span.s3 {text-decoration: underline ; color: #3597fc}table.t1 {border-collapse: collapse}td.td1 {border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #cbcbcb #cbcbcb #cbcbcb #cbcbcb; padding: 0.0px 5.0px 0.0px 5.0px}
$ npm --registry=https://registry.npm.taobao.org install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN network SKIPPING OPTIONAL DEPENDENCY: getaddrinfo ENOTFOUND registry.npm.taobao.org registry.npm.taobao.org:443
問題及解決
問題:
$ npm install -g cnpm --registry=https://registry.npm.taobao.org
....
[ ...] / extract:moment: verb gentlyRm don't care about contents; nuking /usr/lib/node_modules/.staging/moment-846e294d/node_modules
...... 持續(xù)很久.......
[ ...] / preinstall:cnpm: sill doParallel preinstall 643
...... 持續(xù)很久.......
[ ...] \ build:tunnel-agent: verb linkMans tunnel-agent@0.6.0
解決:
重復(fù)幾次,多等些時(shí)間栖茉,后來就好了蚪燕。
擴(kuò)展閱讀
使用npm安裝一些包失敗了的看過來(npm國內(nèi)鏡像介紹)
http://cnodejs.org/topic/4f9904f9407edba21468f31e
簡介:
1.通過config命令
npm config set registry https://registry.npm.taobao.org npm info underscore (如果上面配置正確這個(gè)命令會(huì)有字符串response)
2.命令行指定
npm --registry https://registry.npm.taobao.org info underscore
3.編輯~/.npmrc
加入下面內(nèi)容
registry = https://registry.npm.taobao.org
搜索鏡像: [https://npm.taobao.org](https://npm.taobao.org/)
建立或使用鏡像,參考: [https://github.com/cnpm/cnpmjs.org](https://github.com/cnpm/cnpmjs.org)
淘寶 NPM 鏡像
https://npm.taobao.org/
簡介:
介紹了NPM鏡像源的使用。
$ npm install -g cnpm --registry=https://registry.npm.taobao.org
$ cnpm install [name]
國內(nèi)優(yōu)秀npm鏡像推薦及使用
http://blog.csdn.net/cengjingcanghai123/article/details/45045265
簡介:
淘寶npm鏡像
搜索地址:http://npm.taobao.org/
registry地址:http://registry.npm.taobao.org/
cnpmjs鏡像
搜索地址:http://cnpmjs.org/
registry地址:http://r.cnpmjs.org/
簡介:
cnpmjs.org: Private npm registry and web for Company
So cnpm is meaning: Company npm.
node.js模塊依賴及版本號(hào)
http://www.tuicool.com/articles/2aUB7j
簡介:
Node.js最重要的一個(gè)文件就是package.json,其中的配置參數(shù)決定了功能沐兰。例如下面就是一個(gè)例子
nodejs npm常用命令
http://www.cnblogs.com/linjiqin/p/3765772.html
簡介:
介紹了比較多的項(xiàng)目梧喷。
npm是一個(gè)node包管理和分發(fā)工具,已經(jīng)成為了非官方的發(fā)布node模塊(包)的標(biāo)準(zhǔn)拉背。有了npm师崎,可以很快的找到特定服務(wù)要使用的包,進(jìn)行下載去团、安裝以及管理已經(jīng)安裝的包抡诞。
npm使用國內(nèi)源鏡像(npm下載包失敗的問題)
http://www.reibang.com/p/0deb70e6f395
https://blog.csdn.net/pkx1993/article/details/87987292
簡介:
這里的介紹很好..
簡介:
博客遷移到GitHub穷蛹,采用issues方式發(fā)布
國內(nèi)優(yōu)秀npm鏡像推薦及使用