49

I'm new to Node.js, and I'm going through a few tutorials. For some reason, I can't install any new node modules.

I am using: Mac OSX 10.7.4, Node v. 0.8.6, NPM v. 1.1.48.

I run npm install X and I always get a

npm ERR! fetch failed https://registry.npmjs.org/-/X
npm ERR! Error: 404 Not Found

When I actually go to the npmjs registry, I can see the project page, but no matter which tarball link I hit, it's always the same:

{
    "error": "not_found",
    "reason": "document not found"
}

For example, I tried installing fs by running npm install fs and I get:

npm http GET https://registry.npmjs.org/fs
npm http 200 https://registry.npmjs.org/fs
npm http GET https://registry.npmjs.org/-/fs-0.0.0.tgz
npm http 404 https://registry.npmjs.org/-/fs-0.0.0.tgz
npm ERR! fetch failed https://registry.npmjs.org/-/fs-0.0.0.tgz
npm ERR! Error: 404 Not Found
npm ERR!     at null.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/fetch.js:47:16)
npm ERR!     at EventEmitter.emit (events.js:115:20)
npm ERR!     at WriteStream.flush (fs.js:1514:12)
npm ERR!     at fs.close (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:92:5)
npm ERR!     at Object.oncomplete (fs.js:297:15)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Darwin 11.4.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "fs"
npm ERR! cwd /Users/comocomo/Documents/workspace/nodeTest
npm ERR! node -v v0.8.6
npm ERR! npm -v 1.1.48
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/comocomo/Documents/workspace/nodeTest/npm-debug.log
npm ERR! not ok code 0

I tried fs, fs-extra, express, and formidable, all giving me the same 404 response. There must be something wrong on my part, I'm pretty sure the whole registry is not broken.

Am I using an old registry? Should I change it in my config file? I honestly would rather not start installing things manually, and I'm sure it's just a small configuration issue.

Thanks!

Ido Cohn
  • 1,685
  • 3
  • 21
  • 28

7 Answers7

96

I found the there is a certificate expired issue with:

npm set registry https://registry.npmjs.org/

So I made it http, not https :-

npm set registry http://registry.npmjs.org/

And have no problems so far.

Ben
  • 54,723
  • 49
  • 178
  • 224
Ian S Williams
  • 1,077
  • 8
  • 2
10

The repository is not down, it looks like they've changed how they host files (I guess they have restored some old code):

Now you have to add the /package-name/ before the -

Eg:

http://registry.npmjs.org/-/npm-1.1.48.tgz
http://registry.npmjs.org/npm/-/npm-1.1.48.tgz

There are 3 ways to solve it:

  • Use a complete mirror:
  • Use a public proxy:

    --registry http://165.225.128.50:8000

  • Host a local proxy:

    https://github.com/hughsk/npm-quickfix

git clone https://github.com/hughsk/npm-quickfix.git
cd npm-quickfix
npm set registry http://localhost:8080/
node index.js

I'd personally go with number 3 and revert to npm set registry http://registry.npmjs.org/ as soon as this get resolved.

Stay tuned here for more info: https://github.com/isaacs/npm/issues/2694

framp
  • 813
  • 11
  • 22
  • This is true, I tried to put the package name after base url i.e. http://registry.npmjs.org/ it worked for all of them. Seems NPM is not suffixing the package name before "/-/" in the URL. – Abhinav Gupta Aug 12 '12 at 12:37
  • This does work, but there's no way of telling npm to use the link that way. I'm installing mongoose: npm install http://registry.npmjs.org/mongoose/-/mongoose-3.0.1.tgz So it starts downloading mongoose, but also all the dependencies. The mongoose can be downloaded, but the dependencies can't because the repository's links are still broken. Now I'm downloading them one by one transitively (dependencies before the module), but I'm feeling pretty dumb. Is there an alternative way? – Ido Cohn Aug 12 '12 at 12:48
  • In the end I just did this - manually installing dependencies. Thanks, I gave this answer a +1, but it's not the answer. I'd appreciate an answer so I could close the question. – Ido Cohn Aug 12 '12 at 13:25
  • Yes. This is only one solution which is worked for me. – TonyB Nov 14 '17 at 15:12
9

Npm repository is currently down. See issue #2694 on npm github

EDIT:
To use a mirror in the meanwhile:

 npm set registry http://ec2-46-137-149-160.eu-west-1.compute.amazonaws.com

you can reset this later with:

 npm set registry https://registry.npmjs.org/

source

Elad
  • 19,079
  • 18
  • 62
  • 71
3

This error might also occur due to proxy settings, once check that your proxy allow the access to npm commands.

It worked for me quite well.

1
npm set registry http://85.10.209.91/

(this proxy fetches the original data from registry.npmjs.org and manipulates the tarball urls to fix the tarball file structure issue).

The other solutions seem to have outdated versions.

1

If you happened to run npm install command on Windows, first make sure you open your command prompt with Administration Privileges. That's what solved the issue for me.

gdrt
  • 3,160
  • 4
  • 37
  • 56
0

Check under security settings Allow Apps Downloaded from:

  • App Store and other identified developers

This was one of the reasons I faced recently.

Varun
  • 1
  • 1