Recently my computer is unable to run npm install.
I know this question was already asked, anyway I have checked many similar questions and still didn't help. So I add more information with my attempts, just under the following code.
The problem first.
$ npm install -dd
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
npm verb cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli 'install',
npm verb cli '-dd' ]
npm info using npm@5.6.0
npm info using node@v8.11.3
npm verb npm-session 6b461ab74bbc6682
npm info lifecycle rcm-client@1.0.0~preinstall: rcm-client@1.0.0
npm http fetch GET 200 https://registry.npmjs.org/grunt-contrib-copy 358ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt-contrib-uglify 360ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt-cli 364ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt-contrib-concat 363ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/archiver 369ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt-contrib-clean 364ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt-contrib-jshint 363ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/jshint 268ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt-war 272ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt-replace 275ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt-stryker 274ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/jasmine-core 273ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt-karma 284ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt-sonar-runner 278ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/karma-ie-launcher 278ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/karma-junit-reporter 282ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/karma 287ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/karma-coverage 284ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/karma-jasmine 284ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/karma-ng-html2js-preprocessor 287ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/karma-phantomjs-launcher 287ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/phantomjs-prebuilt 271ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/karma-script-launcher 321ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/stryker 313ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/stryker-api 317ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/stryker-html-reporter 312ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/karma-spec-reporter 322ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/stryker-jasmine 313ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt-angular-templates 1303ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt 1308ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/angular-mocks 1324ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/stryker-karma-runner 274ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/angular 249ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/angular-ui-bootstrap 250ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/angular-route 253ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/angular-utils-pagination 251ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/angular-utils-pagination 253ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/angular-ui-bootstrap 267ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/angular 271ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/angular-route 273ms (from cache)
npm verb stack SyntaxError: Unexpected token < in JSON at position 0 while parsing near '<html><head><meta co...'
npm verb stack at JSON.parse (<anonymous>)
npm verb stack at parseJson (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\node_modules\json-parse-better-errors\index.js:7:17)
npm verb stack at consumeBody.call.then.buffer (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\src\body.js:96:50)
npm verb stack at <anonymous>
npm verb stack at process._tickCallback (internal/process/next_tick.js:188:7)
npm verb cwd C:\git_workspace\rcm-client
npm verb Windows_NT 6.1.7601
npm verb argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-dd"
npm verb node v8.11.3
npm verb npm v5.6.0
npm ERR! Unexpected token < in JSON at position 0 while parsing near '<html><head><meta co...'
npm verb exit [ 1, true ]
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\xxxxxxx\AppData\Roaming\npm-cache\_logs\2018-07-13T07_59_49_943Z-debug.log
All people around me (in the same office, network, proxy etc.) don't have that problem, and my computer was able to run that command previously. It seems it's not a problem with connection, since I found here ( Check for internet connectivity in NodeJs ) the following function to check if URLs can be resolved, and it get the answer "Connected"
require('dns').resolve('www.wikipedia.com', function(err) {
if (err) {
console.log("No connection");
} else {
console.log("Connected");
}
});
> Connected
Even if I cleaned the cache, you can see that every url is taken from cache:
- I manually removed the cache in
C:\Program Files\nodejs
and from command line i runnpm cache clean --force
. Where else can this cache be? - I don't have any
package-lock.json
file, and anyway i removed thenode_modules
folder in the project. - I uninstalled and reinstalled the latest nodejs, as you can see in the error log.
Any hint?