Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js npm install express failed to fetch from registry [duplicate]

Tags:

I am starting my first Node.js server. I am attempting to follow a tutorial in Node.js.

Having installed Node.js and executed npm install, the next instruction is to start the server by running node server.js which generates the following error:

node.js:201     throw e; // process.nextTick error, or 'error' event on first tick           ^ Error: Cannot find module 'express'     at Function._resolveFilename (module.js:332:11)     at Function._load (module.js:279:25)     at Module.require (module.js:354:17)     at require (module.js:370:17)     at Object.<anonymous> (/home/sisko/Desktop/ExerciseFiles/01/03/start/server.js:1:77)     at Module._compile (module.js:441:26)     at Object..js (module.js:459:10)     at Module.load (module.js:348:32)     at Function._load (module.js:308:12)     at Array.0 (module.js:479:10) sisko@VirtualBox:~/Desktop/ExerciseFiles/01/03/start$  

It seemed it needed a module called express so I looked around and found the npm install express command which should fix the issue. However, I get the following error:

sisko@VirtualBox:~/Desktop/ExerciseFiles/01/03/start$ npm install express  npm http GET https://registry.npmjs.org/express  npm ERR! Error: failed to fetch from registry: express npm ERR!     at /usr/share/npm/lib/utils/npm-registry-client/get.js:139:12 npm ERR!     at cb (/usr/share/npm/lib/utils/npm-registry-client/request.js:31:9) npm ERR!     at Request._callback (/usr/share/npm/lib/utils/npm-registry-client/request.js:136:18) npm ERR!     at Request.callback (/usr/lib/nodejs/request/main.js:119:22) npm ERR!     at Request.<anonymous> (/usr/lib/nodejs/request/main.js:212:58) npm ERR!     at Request.emit (events.js:88:20) npm ERR!     at ClientRequest.<anonymous> (/usr/lib/nodejs/request/main.js:412:12) npm ERR!     at ClientRequest.emit (events.js:67:17) npm ERR!     at HTTPParser.onIncoming (http.js:1261:11) npm ERR!     at HTTPParser.onHeadersComplete (http.js:102:31) npm ERR! You may report this log at: npm ERR!     <http://bugs.debian.org/npm> npm ERR! or use npm ERR!     reportbug --attach /home/sisko/Desktop/ExerciseFiles/01/03/start/npm-debug.log npm npm ERR!  npm ERR! System Linux 3.2.0-52-generic npm ERR! command "node" "/usr/bin/npm" "install" "express" npm ERR! cwd /home/sisko/Desktop/ExerciseFiles/01/03/start npm ERR! node -v v0.6.12 npm ERR! npm -v 1.1.4 npm ERR! message failed to fetch from registry: express npm ERR!  npm ERR! Additional logging details can be found in: npm ERR!     /home/sisko/Desktop/ExerciseFiles/01/03/start/npm-debug.log npm not ok 
like image 460
sisko Avatar asked Apr 12 '14 03:04

sisko


2 Answers

For some people running npm config set registry http://registry.npmjs.org/ before npm install express seems to fix that issue

like image 69
bakkal Avatar answered Oct 27 '22 20:10

bakkal


This helps as an alternative solution to accepted answer:

npm config set strict-ssl false 

The problem with npm is that the default registry ssl certificate is not recognized properly.

like image 40
hegemon Avatar answered Oct 27 '22 22:10

hegemon