npm install not working

Problem

I just started learning node.js and i have installed node.js along with npm module manager. I have created a package.json file and from the root directory iam trying to execute npm install command, instead of creating npm_modules folder it throws error like this:

C:\Users\username\Desktop\nodetest>npm install
npm WARN package.json backbone-library@0.0.1 No README.md file found!
npm http GET https://registry.npmjs.org/mongoose
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/path
npm http GET https://registry.npmjs.org/path
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/mongoose
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/path
npm http GET https://registry.npmjs.org/mongoose
npm ERR! Error: connect ETIMEDOUT
npm ERR!     at errnoException (net.js:863:11)
npm ERR!     at Object.afterConnect [as oncomplete] (net.js:854:19)
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 Windows_NT 6.1.7600
npm ERR! command "D:\\Program Files\\nodejs\\\\node.exe" "D:\\Program Files\\no
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd C:\Users\username\Desktop\nodetest
npm ERR! node -v v0.10.0
npm ERR! npm -v 1.2.14
npm ERR! syscall connect
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Users\username\Desktop\nodetest\npm-debug.log
npm ERR! not ok code 0

Iam using Windows 7 OS.

Any ideas ?

Thanks, Srinivas

Problem courtesy of: Srinivas

Solution

This will solve your problem

npm config set proxy proxy-url:port (http:\proxy-name:port)

npm config set https-proxy proxy-url:port

Solution courtesy of: khurrum qureshi

Discussion

finally i came to know that my company laptop has proxy restrictions.Once i got the approval for proxy removal it worked.

Discussion courtesy of: Srinivas
  1. If you are working behind a proxy, configure it:

npm config set proxy http://login:pass@host:port

  1. Check the value of your proxy configuration:

npm config get http-proxy

  1. Try again to get your package...
Discussion courtesy of: Arthur

You may need to use the windows "run as" command (which is equivalent to the *nix "sudo" command) in order to have the correct privileges on your machine.

This link should be helpful: https://superuser.com/questions/42537/is-there-any-sudo-command-for-windows

Discussion courtesy of: ZenBalance

Adding to the selected answer

a) "npm config set proxy proxy-url:port (http:\proxy-name:port)

b) npm config set https-proxy proxy-url:port"

make sure you add "http:\\" to your proxy name, and packages downloaded from npm use ssl so try the second option for sure.

Discussion courtesy of: Bot

It was a stuck step on my side,

the following syntax worked for me:

npm config set proxy http:/myproxyserver:port

best regards :)

Discussion courtesy of: Ramiro Juarez

But still ppl, who ever facing proxy issue in npm install,can try the following method.

Go to C:\Users\YourUserName
Create a file named .npmrc (no need of any prefixname just .npmrc)
Inside that file type the following

proxy = username:password@ip:port (add http:// before username)

That's all.It is perfectly working for me....

Discussion courtesy of: Gopinath Gunanithi

The traceroute command will usually tell you where a connection fails and would have lead you straight to the corporate proxy in this case.

Discussion courtesy of: Darren White

This recipe can be found in it's original form on Stack Over Flow.