废话不多说,直接上图
最近把项目下过来,npm install grunt-cli以及npm install grunt 都执行成功,但是就npm install 时不成功,查看控制台是phantomJs安装不成功,之后各种重装系统以及安装vs,但是这样做还是会出现这个错误,哦对了,之前还有一个msbuild错误,那个是因为没有安装vs或者是python导致的,安装了就好了。
解决方法:
安装nrm,使用nrm把npm的源切换成国内的
➜ ~ sudo npm i nrm -g # 安装nrm
Password:
/usr/local/bin/nrm -> /usr/local/lib/node_modules/nrm/cli.js
- assert-plus@1.0.0 node_modules/nrm/node_modules/dashdash/node_modules/assert-plus
- assert-plus@1.0.0 node_modules/nrm/node_modules/getpass/node_modules/assert-plus
- graceful-readlink@1.0.1 node_modules/nrm/node_modules/graceful-readlink
- jodid25519@1.0.2 node_modules/nrm/node_modules/jodid25519
- assert-plus@1.0.0 node_modules/nrm/node_modules/jsprim/node_modules/assert-plus
- assert-plus@1.0.0 node_modules/nrm/node_modules/sshpk/node_modules/assert-plus
/usr/local/lib
└─┬ nrm@1.0.2
├── commander@2.11.0
├── extend@3.0.1
└─┬ request@2.83.0
├── aws-sign2@0.7.0
├── form-data@2.3.1
├─┬ har-validator@5.0.3
│ ├─┬ ajv@5.2.3
│ │ ├── fast-deep-equal@1.0.0
│ │ └── json-schema-traverse@0.3.1
│ └── har-schema@2.0.0
├─┬ hawk@6.0.2
│ ├── boom@4.3.1
│ ├─┬ cryptiles@3.1.2
│ │ └── boom@5.2.0
│ ├── hoek@4.2.0
│ └── sntp@2.0.2
├─┬ http-signature@1.2.0
│ ├── assert-plus@1.0.0
│ ├─┬ jsprim@1.4.1
│ │ ├── extsprintf@1.3.0
│ │ └─┬ verror@1.10.0
│ │ └── core-util-is@1.0.2
│ └─┬ sshpk@1.13.1
│ └── getpass@0.1.7
├─┬ mime-types@2.1.17
│ └── mime-db@1.30.0
├── performance-now@2.1.0
├── qs@6.5.1
├── safe-buffer@5.1.1
├── tough-cookie@2.3.3
└── uuid@3.1.0
➜ ~ nrm # 查看使用方法
Usage: nrm [options] [command]
Options:
-V, --version output the version number
-h, --help output usage information
Commands:
ls List all the registries
current Show current registry name
use <registry> Change registry to registry
add <registry> <url> [home] Add one custom registry
del <registry> Delete one custom registry
home <registry> [browser] Open the homepage of registry with optional browser
test [registry] Show response time for specific or all registries
help Print this help
➜ ~ nrm ls # 列出可用的npm源
* npm ---- https://registry.npmjs.org/
cnpm --- http://r.cnpmjs.org/
taobao - https://registry.npm.taobao.org/
nj ----- https://registry.nodejitsu.com/
rednpm - http://registry.mirror.cqupt.edu.cn/
npmMirror https://skimdb.npmjs.com/registry/
edunpm - http://registry.enpmjs.org/
➜ ~ nrm use taobao # 使用淘宝的nrm源
verb config Skipping project config: /Users/dangjian/.
Registry has been set to: https://registry.npm.taobao.org/
➜ ~
切换完后,删除你的node_modules文件夹,重新进行安装
Enjoy IT