Sheng
Sheng

Reputation: 451

npm install is so fragile on windows

I have a project using grunt build. Here is my 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"
},
...

I'm running npm 1.4.13 and node v0.10.28

There is always some random errors occur when I run clean npm install. And every time it is a different module. Then I have to run npm cache clean if the error is from the cache folder, or delete the node_modules if the error is in node_modules folder. Then I have to retry several times to bypass the error. I tried windows 8, windows 7, and windows server 2008. Here is one of the error logs.

C:\src>npm install
npm ERR! unpack Could not read data for [email protected]
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

And sometimes it just failed to fetch modules from registry. For example:

npm WARN package.json [email protected] 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

I thought the remote npm registry was not stable, so I setup a local npm registry mirror. But the error still occurs. I don't know why npm is so unstable on windows.

Upvotes: 3

Views: 1114

Answers (1)

Paul Sweatte
Paul Sweatte

Reputation: 24627

npm ERR! registry error parsing json

The package.json file for the module in question is missing or has a syntax error

npm ERR! Error: failed to fetch from registry: lodash

The module in question is not in the registry

npm ERR! cwd C:\src

The path in question does not exist

npm ERR! Error: ENOENT, chmod 'C:\src\node_modules\l

No permissions to modify the path in question

Verify the installation process:

  • Did you install as an admin, then run npm as a regular user?
  • Did you install nodeJS into a protected directory?
  • Did you set your PATH correctly?

References

Upvotes: 1

Related Questions