前端

[总结] npm使用备忘

2016-09-25  本文已影响799人  mr_franklin

设置国内registry,加快下载速度

npm config set registry https://registry.npm.taobao.org/)
npm --registry=https://registry.npm.taobao.org install express
vi ~/.npmrc
registy=https://registry.npm.taobao.org/

npm install时报错:

npmERR!registry error parsing json

原因:国内registry挂了,临时切换到国外源来解决这个问题:

npm cache clear
npm config set registry http://registry.npmjs.org/

如果想查看某个nodejs项目在github上的issues,可以运行命令:

npm issues express

npm update的时候报错:

npm ERR! Linux 3.10.0-229.11.1.el7.x86_64
npm ERR! argv "/home/daheng/.nvm/versions/node/v5.7.0/bin/node" "/home/daheng/.nvm/versions/node/v5.7.0/bin/npm" "update"
npm ERR! node v5.7.0
npm ERR! npm  v3.6.0

npm ERR! No compatible version found: node.extend@linked
npm ERR! Valid install targets:
npm ERR! 1.1.6, 1.1.5, 1.1.4, 1.1.3, 1.1.2, 1.1.1, 1.1.0, 1.0.10, 1.0.9, 1.0.8, 1.0.7, 1.0.6, 1.0.5, 1.0.4, 1.0.3, 1.0.2, 1.0.1, 1.0.0, 0.0.1
npm ERR! 
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

原因:git切换分支版本后才报错,应该是node_modules下面的文件混乱了。把整个目录都删除再从新npm instal,npm update。

npm install和npm update的区别:

区别只在于那些已经安装的,模糊版本的依赖包。
package.json

{
  "name":          "my-project",
  "version":       "1.0",                             // install   update
  "dependencies":  {                                  // ------------------
    "already-installed-versionless-module":  "*",     // ignores   "1.0" -> "1.1"
    "already-installed-semver-module":       "^1.4.3" // ignores   "1.4.3" -> "1.5.2"
    "already-installed-versioned-module":    "3.4.1"  // ignores   ignores
    "not-yet-installed-versionless-module":  "*",     // installs  installs
    "not-yet-installed-semver-module":       "^4.2.1" // installs  installs
    "not-yet-installed-versioned-module":    "2.7.8"  // installs  installs
  }
}

转自:http://stackoverflow.com/questions/12478679/npm-install-vs-update-whats-the-difference

上一篇下一篇

猜你喜欢

热点阅读