npm无法安装时,国内被墙的解决方法。

你可以使用我们定制的cnpm(gzip压缩支持)命令行工具代替默认的npm:

$npminstall-gcnpm--registry=https://registry.npm.taobao.org

或者你直接通过添加npm参数alias一个新命令:

aliascnpm="npm--registry=https://registry.npm.taobao.org\

--cache=$HOME/.npm/.cache/cnpm\

--disturl=https://npm.taobao.org/dist\

--userconfig=$HOME/.cnpmrc"


#Oraliasitin.bashrcor.zshrc

$echo'\n#aliasforcnpm\naliascnpm="npm--registry=https://registry.npm.taobao.org\

--cache=$HOME/.npm/.cache/cnpm\

--disturl=https://npm.taobao.org/dist\

--userconfig=$HOME/.cnpmrc"'>>~/.zshrc&&source~/.zshrc安装模块

从registry.npm.taobao.org安装所有模块.当安装的时候发现安装的模块还没有同步过来,淘宝NPM会自动在后台进行同步,并且会让你从官方NPMregistry.npmjs.org进行安装.下次你再安装这个模块的时候,就会直接从淘宝NPM安装了.

$cnpminstall[name]同步模块

直接通过sync命令马上同步一个模块,只有cnpm命令行才有此功能:

$cnpmsyncconnect

当然,你可以直接通过web方式来同步:/sync/connect

$openhttps://npm.taobao.org/sync/connect其它命令

支持npm除了publish之外的所有命令,如:

$cnpminfoconnect