NPM?
Install Node & NPM
Node Version Control
n / nvm / nvmw
https://github.com/creationix/nvm
npm install -g n // 目录/usr/local/bin
https://github.com/hakobera/nvmw
对比:http://taobaofed.org/blog/2015/11/17/nvm-or-n/
Install npm packages
包的源问题:
临时使用:
npm --registry https://registry.npm.taobao.org install express
持久使用:
npm config set registry https://registry.npm.taobao.org
// 配置后可通过下面方式来验证是否成功
npm config get registry
// 或
npm info express
通过cnpm使用:
npm install -g cnpm --registry=https://registry.npm.taobao.org
// 使用
cnpm install express
安装包:
npm install <package-name>@<version>
npm install -g <package-name>
// mac / Unix 权限问题
sudo npm install -g <package-name>
http://www.cnblogs.com/kaiye/p/4937191.html
node 命令在 /usr/local/bin/node ,
npm 命令在/usr/local/lib/node_modules/npm
全局命令都在/usr/local/lib/node_modules/
下
区分:
If you want to use it as a command line tool, something like the grunt CLI, then you want to install it globally. On the other hand, if you want to depend on the package from your own module using something like Node's require, then you want to install locally.
Semantic versioning and npm
If a project is going to be shared with others, it should start at 1.0.0, though some projects on npm don't follow this rule.
After this, changes should be handled as follows:
Bug fixes and other minor changes: Patch release, increment the last number, e.g. 1.0.1
New features which don't break existing features: Minor release, increment the middle number, e.g. 1.1.0
Changes which break backwards compatibility: Major release, increment the first number, e.g. 2.0.0
更新&卸载包
Local:(在项目的package.json同级目录下)
查看过期的包:
npm outdated
更新过期的包:
npm update
注:有时候会更新不成功,多运行几次
卸载:
npm uninstall <package>
从package.json中删除:
npm uninstall --save <package>
or
npm uninstall --save-dev <package>
Global:
查看过期包:
npm outdated -g --depth=0
更新过期包:
npm install -g <package>
or
npm update -g
卸载:
npm uninstall -g <package>
npm publish
没有注册使用:
npm adduser
注册以后:
npm login
验证是否登录:
npm who am i
注:==npm login /npm adduser 一定要先切回原地址==
npm config set registry http://registry.npmjs.org
http://www.cnblogs.com/pingfan1990/p/4824658.html
参考: