Last Updated: September 09, 2019
·
48.65K
· harshadkale

installing npm packages on Windows

UPDATE - NO NEED TO FOLLOW THIS TIP NOW. NODE SINCE VERSIONS > 0.6 INSTALL NPM ALONG WITH ITSELF

If you are trying to install nom packages on Windows, you will face all sorts of problems.

My machine configuration -
Microsoft Windows 8 Release Preview

While executing "npm install express" and then "npm install" it always threw me an error saying that the dependencies cannot be read. I followed a few logical steps and now it works. I am not sure exactly what part of my steps fixed it, but if you have these problems, worth trying!

  1. Run 'cmd' as Administrator

  2. Make sure your PATH environment variable points to the right location of nodejs, typically C:\Program Files\nodejs.

  3. Back to cmd, cd into (go to) C:\Program Files\nodejs\nodemodules\npm\nodemodules

  4. Clear npm cache by npm cache clear

  5. Run command npm install {package_name} -g - it could be Express, Jade etc. It will create a package folder in current location.

  6. It will create folders under C:\Users{yourusername}\AppDate\Roaming\npm\nodemodules. Copy paste all the folders under this node_modules to C:\Program Files\nodejs\nodemodules\npm\nodemodules.

  7. Add entry of the dependencies (of the packages you want to install in the package.json under C:\Program Files\nodejs\node_modules\npm\package.json as
    "express": "{version}",
    This latest version can be found out by running npm info express version on cmd.

  8. cd into (go into) that created package folder and run npm install -g (-g installs it globally)

Done!

I am sure there is easier way to do all this and the way I did may not be the appropriate way, rather it is not. But I do not know any other way so, this should work for you too.

If you happen to know easier and appropriate way, you are more than welcome to describe it in the comments below.

4 Responses
Add your response

Thanks, I had the same on vindows 7, you helped me.

over 1 year ago ·

Glad to hear that

over 1 year ago ·

Just a note to add, in case others are running into this: "nodemodules" should be "node_modules" in the path. This looks to be the result of writing the original post in markdown (what is between undersores is italicized.)

over 1 year ago ·

How to run and start that project on windows that built

over 1 year ago ·