76

I had some issues trying to install Node on Windows 10 and found the solution.

The error was as follows:

C:\Users\Stephan>npm
Error: ENOENT, stat 'C:\Users\Stephan\AppData\Roaming\npm'

The solution is below.

neophyte
  • 6,540
  • 2
  • 28
  • 43
Stephan Bijzitter
  • 4,425
  • 5
  • 24
  • 44

10 Answers10

144

Edit: It seems like new installers do not have this problem anymore, see this answer by Parag Meshram as my answer is likely obsolete now.

Original answer:

Follow these steps, closely:

  • http://nodejs.org/download/ download the 64 bits version, 32 is for hipsters
  • Install it anywhere you want, by default: C:\Program Files\nodejs
  • Control Panel -> System -> Advanced system settings -> Environment Variables
  • Select PATH and choose to edit it.

If the PATH variable is empty, change it to this: C:\Users\{YOUR USERNAME HERE}\AppData\Roaming\npm;C:\Program Files\nodejs

If the PATH variable already contains C:\Users\{YOUR USERNAME HERE}\AppData\Roaming\npm, append the following right after: ;C:\Program Files\nodejs

If the PATH variable contains information, but nothing regarding npm, append this to the end of the PATH: ;C:\Users\{YOUR USERNAME HERE}\AppData\Roaming\npm;C:\Program Files\nodejs

Now that the PATH variable is set correctly, you will still encounter errors. Manually go into the AppData directory and you will find that there is no npm directory inside Roaming. Manually create this directory.

Re-start the command prompt and npm will now work.

Community
  • 1
  • 1
Stephan Bijzitter
  • 4,425
  • 5
  • 24
  • 44
  • 2
    @captainrad so far I have not had any trouble, but I cannot be sure about release before Dec 7 – Stephan Bijzitter Mar 26 '15 at 08:23
  • 1
    @captainrad It worked when I copied files in C:\Program Files\nodejs to C:\Users\{YOUR USERNAME HERE}\AppData\Roaming\npm on Windows 10 – onuralp Mar 28 '15 at 14:19
  • 1
    @DannyG Thanks for your edit, but please only edit when it improves the answer. Refer to http://stackoverflow.com/help/editing for more on this subject. – Stephan Bijzitter Nov 18 '15 at 21:57
  • 4
    Just as a heads up, Stephan, the recent edit/rollback sparked a (not bad) [Meta conversation](http://meta.stackoverflow.com/questions/310646/edit-a-post-that-can-possibly-contain-offensive-unnecesary-text) it might be worth your time to look at. It might give you some more context for why DannyG edited your answer. – Kendra Nov 19 '15 at 16:57
  • I tried to reinstall and it's working now. Path must be in "User variables for {user login name}" listbox, not system variables. – ddagsan May 26 '16 at 07:21
  • 3
    "... is for hipsters" ;-) – crishushu Aug 12 '16 at 10:14
  • October 2017, this answer still applies but the npm folder in Roaming was created in my case but contains no files – DerpyNerd Oct 21 '17 at 10:56
68

go to http://nodejs.org/

and hit the button that says "Download For ..."

This'll download the .msi (or .pkg for mac) which will do all the installation and paths for you, unlike the selected answer.

Shai UI
  • 50,568
  • 73
  • 204
  • 309
  • 1
    Mind explaining why the accepted answer did not work for you? – Stephan Bijzitter Oct 04 '15 at 11:51
  • 11
    The accepted answer required me to manually enter the paths which is not required if you run the installer (.msi). – Shai UI Oct 04 '15 at 14:42
  • 3
    Then either the installer has been updated to automatically do this in the past few weeks, or you just got lucky on your system :-) I do doubt this, however. – Stephan Bijzitter Oct 05 '15 at 06:53
  • 3
    This is the correct answer. If you are on Windows the default install works ( .msi ) ... thanks @foreyez – Scott Stensland Oct 14 '15 at 03:40
  • Definitely the best answer - works fine on windows 10 for me too – munkee Dec 19 '15 at 16:32
  • That sounds sensible but ends up creating a mess (if you do this as admin). I explain in my answer below why you should tell the installer to put it in %appdata% instead. – Tom Nov 17 '17 at 03:53
  • 1
    This should be marked as correct answer as Its just one step solution rather then @StephanBijzitter solution which requires me to first browse their download directory searching for correct versions which I don't know about(not familiar with nodejs). – shivgre Jan 19 '18 at 02:19
  • The installer does not work on Windows 10 at all. It only creates a path to installation folder not roaming. – M. Doosti Lakhani Oct 18 '19 at 10:05
15

In addition to the answer from @StephanBijzitter I would use the following PATH variables instead:

%appdata%\npm
%ProgramFiles%\nodejs

So your new PATH would look like:

[existing stuff];%appdata%\npm;%ProgramFiles%\nodejs

This has the advantage of neiter being user dependent nor 32/64bit dependent.

Dunken
  • 8,481
  • 7
  • 54
  • 87
  • This is great if you've installed it in the default location, but please bear in mind that if you did not, this will only serve to clutter up the PATH variable. – Dave Morton Aug 27 '16 at 10:37
11

New installers (.msi downloaded from https://nodejs.org) have "Add to PATH" option. By default it is selected. Make sure that you leave it checked.

Add to PATH

activedecay
  • 10,129
  • 5
  • 47
  • 71
Parag Meshram
  • 8,281
  • 10
  • 52
  • 88
3

Everything should be installed in %appdata% (C:\Users\\AppData\Roaming), not 'program files'.

Here's why...

The default MSI installer puts Node and the NPM that comes with it in 'program files' and adds this to the system path, but it sets the user path for NPM to %appdata% (c:\users[username]\appdata\roaming) since the user doesn't have sufficient priveleges to write to 'program files'.

This creates a mess as all modules go into %appdata%, and when you upgrade NPM itself - which NPM themselves recommend you do right away - you end up with two copies: the original still in 'program files' since NPM can't erase that, and the new one inn %appdata%.

Even worse, if you mistakenly perform NPM operations as admin (much easier on Windows then on *nix) then it will operate on the 'program files' copy of NPM node_modules. Potentially a real mess.

So, when you run the installer simply point it to %appdata% and avoid all this.

And note that this isn't anything wierd - it’s what would happen if you ran the installer with just user priveleges.

Tom
  • 17,103
  • 8
  • 67
  • 75
2

You should run the installer as administrator.

  1. Run the command prompt as administrator
  2. cd directory where msi file is present
  3. launch msi file by typing the name in the command prompt
  4. You should be happy to see all node commands work from new command prompt shell
arunram
  • 623
  • 7
  • 11
2

I had the same problem, what helped we was turning of my anti virus protection for like 10 minutes while node installed and it worked like a charm.

Adeel Imran
  • 13,166
  • 8
  • 62
  • 77
1

The reason why you have to modify the AppData could be:

  1. Node.js couldn't handle path longer then 256 characters, windows tend to have very long PATH.
  2. If you are login from a corporate environment, your AppData might be on the server - that won't work. The npm directory must be in your local drive.

Even after doing that, the latest LTE (4.4.4) still have problem with Windows 10, it worked for a little while then whenever I try to:

$ npm install _some_package_ --global 

Node throw the "FATAL ERROR CALL_AND_RETRY_LAST Allocation failed - process out of memory" error. Still try to find a solution to that problem.

The only thing I find works is to run Vagrant or Virtual box, then run the Linux command line (must matching the path) which is quite a messy solution.

Joel Chu
  • 828
  • 1
  • 9
  • 25
1

For me I had to delete the nodejs folder in \program files and then when I went to install through the msi it worked. Seemed like when I uninstalled Node it didnt actually delete this file

0

I had the same problem, but after trying everything on this post unsuccessfully, I just had to restart. So if you haven't tried restarting the computer after the installation, try it.

Restart your computer after installation

Alberto
  • 1,423
  • 18
  • 32