我有一个使用grunt构建的项目。这是我的packages.json。
...
"devDependencies": {
"grunt": "^0.4.4",
"grunt-autoprefixer": "^0.7.3",
"grunt-coffeelint": "0.0.10",
"grunt-concurrent": "^0.5.0",
"grunt-connect-proxy": "^0.1.10",
"grunt-contrib-clean": "^0.5.0",
"grunt-contrib-concat": "^0.4.0",
"grunt-contrib-connect": "^0.7.1",
"grunt-contrib-copy": "^0.5.0",
"grunt-contrib-csslint": "^0.2.0",
"grunt-contrib-cssmin": "^0.9.0",
"grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-less": "^0.11.0",
"grunt-contrib-requirejs": "^0.4.4",
"grunt-contrib-stylus": "^0.15.1",
"grunt-contrib-uglify": "^0.4.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-modernizr": "^0.5.2",
"grunt-newer": "^0.7.0",
"jshint-stylish": "^0.2.0",
"load-grunt-tasks": "^0.4.0",
"rjs-build-analysis": "0.0.3",
"time-grunt": "^0.3.1"
},
...
我正在运行npm 1.4.13
和节点v0.10.28
当我运行干净npm install
时,总会发生一些随机错误。每次它都是一个不同的模块。然后,如果错误来自缓存文件夹,则必须运行npm cache clean
,如果错误位于node_modules
文件夹中,则必须删除node_modules
。然后我必须重试几次以绕过错误。我尝试了Windows 8,Windows 7和Windows Server 2008.这是错误日志之一。
C:\src>npm install
npm ERR! unpack Could not read data for sigmund@1.0.0
npm ERR! Error: ENOENT, chmod 'C:\src\node_modules\l
oad-grunt-tasks\node_modules\multimatch\node_modules\minimatch\node_modules\lru-
cache\CONTRIBUTORS'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\src\\packages\\Ncapsulate.Node.0.10.28\\no
dejs\\\\node.exe" "C:\\src\\packages\\Ncapsulate.Node.0.10.28\\n
odejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd C:\src
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.13
npm ERR! path C:\src\node_modules\load-grunt-tasks\n
ode_modules\multimatch\node_modules\minimatch\node_modules\lru-cache\CONTRIBUTOR
S
npm ERR! fstream_path C:\src\node_modules\load-grunt
-tasks\node_modules\multimatch\node_modules\minimatch\node_modules\lru-cache\CON
TRIBUTORS
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! fstream_finish_call chmod
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack C:\src\packages\Ncapsulate.Node.0.10.28\no
dejs\node_modules\fstream\lib\writer.js:305:19
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! Failed to parse json
npm ERR! Unexpected end of input
npm ERR! File: C:\Users\tim\AppData\Roaming\npm-cache\sigmund\1.0.0\package\pack
age.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse
npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\src\\packages\\Ncapsulate.Node.0.10.28\\no
dejs\\\\node.exe" "C:\\src\\packages\\Ncapsulate.Node.0.10.28\\n
odejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd C:\src
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.13
npm ERR! file C:\Users\tim\AppData\Roaming\npm-cache\sigmund\1.0.0\package\packa
ge.json
npm ERR! code EJSONPARSE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\src\npm-debug.log
npm ERR! not ok code 0
有时它无法从注册表中获取模块。例如:
npm WARN package.json rjs-build-analysis@0.0.3 No repository field.
npm ERR! Error: failed to fetch from registry: lodash
npm ERR! at RegClient.<anonymous> (C:\src\packages\Ncapsulate
.Node.0.10.28\nodejs\node_modules\npm-registry-client\lib\get.js:133:18)
npm ERR! at cb (C:\src\packages\Ncapsulate.Node.0.10.28\nodej
s\node_modules\npm-registry-client\lib\request.js:32:9)
npm ERR! at RegClient.<anonymous> (C:\src\packages\Ncapsulate
.Node.0.10.28\nodejs\node_modules\npm-registry-client\lib\request.js:107:16)
npm ERR! at cb (C:\src\packages\Ncapsulate.Node.0.10.28\nodej
s\node_modules\npm-registry-client\lib\request.js:132:9)
npm ERR! at RegClient.<anonymous> (C:\src\packages\Ncapsulate
.Node.0.10.28\nodejs\node_modules\npm-registry-client\lib\request.js:286:12)
npm ERR! at Request._callback (C:\src\packages\Ncapsulate.Nod
e.0.10.28\nodejs\node_modules\npm-registry-client\lib\request.js:212:65)
npm ERR! at Request.self.callback (C:\src\packages\Ncapsulate
.Node.0.10.28\nodejs\node_modules\request\request.js:123:22)
npm ERR! at Request.EventEmitter.emit (events.js:98:17)
npm ERR! at Request.<anonymous> (C:\src\packages\Ncapsulate.N
ode.0.10.28\nodejs\node_modules\request\request.js:893:14)
npm ERR! at Request.EventEmitter.emit (events.js:117:20)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\src\\packages\\Ncapsulate.Node.0.10.28\\no
dejs\\\\node.exe" "C:\\src\\packages\\Ncapsulate.Node.0.10.28\\n
odejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd C:\src\npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.13
npm ERR! registry error parsing json
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\src\npm-debug.log
npm ERR! not ok code 0
我认为远程npm注册表不稳定,所以我设置了一个本地的npm注册表镜像。但错误仍然存在。我不知道为什么npm在Windows上如此不稳定。
答案 0 :(得分:1)
npm ERR!注册表错误解析json
有问题的模块的package.json文件缺失或语法错误
npm ERR!错误:无法从注册表中获取:lodash
有问题的模块不在注册表中
npm ERR! cwd C:\ src
相关路径不存在
npm ERR!错误:ENOENT,chmod&#39; C:\ src \ node_modules \ l
无权修改相关路径
验证安装过程:
<强>参考强>