phonegap 安装环境搭建在网上已经有了很多教程,大部分是通过node.js执行npm install -g phonegap来安装的,但是在执行命令的 时候会报错误:
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs
\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "cordova"
npm ERR! node v0.12.4
npm ERR! npm v2.10.1
npm ERR! shasum check failed for C:\Users\fengjun\AppData\Local\Temp\npm-5272-16
e13159\registry.npmjs.org\glob\-\glob-4.0.6.tgz
npm ERR! Expected: 695c50bdd4e2fb5c5d370b091f388d3707e291a7
npm ERR! Actual: b2eb98b5ee2628a10b44f80e52fab8bd5240589a
npm ERR! From: https://registry.npmjs.org/glob/-/glob-4.0.6.tgz
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\user\npm-debug.log
主要原因是网络代理出错了。使用下面的方法就可以就解决这个问题了
使用npm国内镜像
镜像使用方法(三种办法任意一种都能解决问题,建议使用第1或者第3种,将配置写死,下次用的时候配置还在):
1.通过config命令
npm config set registry https://registry.npm.taobao.org
npm info underscore (如果上面配置正确这个命令会有字符串response)
2.命令行指定
npm --registry https://registry.npm.taobao.org info underscore
3.编辑 ~/.npmrc 加入下面内容
registry = https://registry.npm.taobao.org
另外网上说使用goagent做代理,但是未成功,照理应该可行的:
打开goagent,默认代理地址为127.0.0.1:8087
设置npm代理指向
npm config set https-proxy http://127.0.0.1:8087
将https严格模式改为false
npm config set strict-ssl false
使用上面的方法可以很轻松的解决这个问题。