997

I have Windows 7 32-bit. I installed the latest Node.js 32 bit.
When I try to run the command npm install jquery, I receive the error:

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

How does one resolve it?

Arsen Khachaturyan
  • 6,472
  • 4
  • 32
  • 36
tryasko
  • 10,099
  • 3
  • 11
  • 6
  • 6
    Try running the command prompt as administrator. – skjagini Aug 13 '14 at 00:52
  • 3
    Run command prompt as administrator, and create the folder. – James Westgate Oct 29 '14 at 09:37
  • To remember the error, you can read it like "Error: NO ENTry". So check the directory whether it exists, otherwise create a new one. If there's no access, you can run the command prompt as administrator. Though for no access error node.js normally arise EACCESS error. – codersaif Jul 10 '15 at 07:11
  • Googlers, also note, that you can get this message as an ‘not found answer’ to small path typos, i.e. `res.sendfile('pathSlightlyWrong/posts.html')` (experienced under Windows 7) – Frank Nocke Apr 18 '16 at 08:37
  • My Unhandled event error got fixed in this answer https://stackoverflow.com/a/52441411/6665568 – Natesh bhat Jan 03 '19 at 13:42

7 Answers7

1802

Manually creating a folder named 'npm' in the displayed path fixed the problem.

More information can be found on Troubleshooting page

Ilya Palkin
  • 11,463
  • 2
  • 21
  • 35
Torsten
  • 20,826
  • 5
  • 22
  • 30
  • 27
    Seems like a bug on the instller. – amcdnl Aug 04 '14 at 13:40
  • 35
    Is this bug in some tracker? This makes for an awful first experience with nodejs... – Roman Starkov Aug 10 '14 at 16:32
  • 21
    This appears a bug with a recent release of Node.js. It wasn't an issue a few months ago. I had to manually create the folder to make it work on Windows 8.1 x64. – Sahas Katta Aug 20 '14 at 19:51
  • 2
    It's being tracked by https://github.com/npm/npm/issues/5905, so you can subscribe to that issue to see progress. – David Ebbo Aug 21 '14 at 17:38
  • After creating the missing directory, you can set the prefix to the right path using npm config get prefix / npm config set prefix xxxxx. Then you can remove the created directory again. – maryo Aug 24 '14 at 09:14
  • I logged in just to one up this. – Dnaso Aug 26 '14 at 18:23
  • 1
    @Dnaso, same here -- still relevant to latest download – Catalyst Sep 06 '14 at 00:30
  • I can confirm that this works on my laptop with 64bit Node, while the error reproduces on the Dell Venue with 32bit Node. – KFL Sep 08 '14 at 04:16
  • 3
    For those who land here later, this is a reported issue at [npm/npm#5905](https://github.com/npm/npm/issues/5905) and [joyent/node#8117](https://github.com/joyent/node/issues/8117) – Chad Sep 09 '14 at 15:19
  • 1
    I would introduce such a bug just to get the >3K points for this answer on SO :) – Jonathan Sep 13 '14 at 15:09
  • GREAT! Wow.. what a frustrating bug. Thanks for the easy fix – ladieu Sep 22 '14 at 14:38
  • 1
    I had to *delete* the existing `npm` directory and then re-create it. – adam-p Sep 22 '14 at 19:09
  • Had the same problem on Windows 7 64bit. Still not fixed. Maybe it has something to do with running cmd without admin rights? – Velter Oct 14 '14 at 19:13
  • Manually creating the directory and/or running the command as admin didn't work for me on Win7/64. I ran 'npm install [stuff]' without '-g' which worked. Now it also accepts '-g'. – robsn Oct 15 '14 at 17:44
  • 8
    btw 3 months later it's still not fixed :( – Sliq Nov 06 '14 at 13:38
  • 1
    still an issue on windows 7 and windows 8.1 , i always arrive here after installing node :) – eran otzap Dec 27 '14 at 21:22
  • @maryo: Can you please clarify: "After creating the missing directory, you can set the prefix to the right path using npm config get prefix / npm config set prefix xxxxx. Then you can remove the created directory again." What's the "right" path? – aliteralmind Feb 04 '15 at 14:53
  • I've set it to D:\Program Files\nodejs\node_modules\npm but that's because i use only one user account, previously it was set to something in C:\Users\ – maryo Mar 16 '15 at 13:41
  • My error path is 'path/to/out.min.js' and I just named a new folder called 'out.min.js' and it worked!! I'm still confused why that works, but it does... – Vicky Zhang Jun 16 '15 at 19:45
  • for me what worked was, manually create a '.npm_modules' folder, because I already had the 'npm' folder – torrao Feb 11 '16 at 18:39
106

I ran into the same problem while installing a package via npm.

After creating the npm folder manually in C:\Users\UserName\AppData\Roaming\ that particular error was gone, but it gave similar multiple errors as it tried to create additional directories in the npm folder and failed. The issue was resolved after running the command prompt as an administrator.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Aniket Thakur
  • 58,991
  • 35
  • 252
  • 267
  • 6
    Yeah same for me - Win7 and 64 bit. You need to create new folder and then execute npm command on command prompt run as administrator. – Aniket Thakur Oct 28 '14 at 06:08
  • 1
    Same thing for me in Windows 10. Thanks for the tip. – Nate Jan 22 '15 at 21:05
  • It worked after reinstalling node, removing npm and npm-cache folders in C:\Users\UserName\AppData\Roaming\ and added the folders again in command prompt as an admin. – Jens Stigaard Apr 07 '16 at 20:11
88

This can also be fixed by installing a node package manually.

npm install npm -g

The process of doing that will setup all the required directories.

Sushruth
  • 766
  • 5
  • 13
NStorm
  • 1,000
  • 11
  • 19
  • 1
    This is the only one that worked for me. Need to use -g for 'Global Mode' so it installs the packages into your . It will place them in the 'node_modules' folder. Otherwise, it will run in local mode and attempt to place the files and directories into the whichever path you are currently in. Sometimes, even running as administrator, you will run into directory access issues. – Justin Russo Jan 25 '15 at 14:10
  • This is the only solution that worked for me as well running Win 8.1 with the 64-bit installer. Thanks! – RyGuy Jan 28 '15 at 20:59
  • 4
    This is the cleanest solution! – Dennkster Feb 04 '15 at 11:43
  • 1
    this also worked when hitting the same problem on OSX, albeit with a different file path – Ed Sykes Mar 25 '15 at 15:27
10

I recommend setting an alternative location for your npm modules.

npm config set prefix C:\Dev\npm-repository\npm --global 
npm config set cache C:\Dev\npm-repository\npm-cache --global  

Of course you can set the location to wherever best suits.

This has worked well for me and gets around any permissions issues that you may encounter.

Reece
  • 635
  • 2
  • 8
  • 24
2

You can go to the Start Menu and search the Node.js icon and open the shell and then install anything with

install <packagename> -g
EliuX
  • 7,605
  • 4
  • 35
  • 37
0

Install a stable version instead of the latest one, I have downgrade my version to node-v0.10.29-x86.msi from 'node-v0.10.33-x86.msi' and it is working well for me!

http://blog.nodejs.org/2014/06/16/node-v0-10-29-stable/

Sagar Awasthi
  • 502
  • 5
  • 10
0

I needed a package from github that was written in typscript. I did a git pull of the most recent version from the master branch into the root of my main project. I then went into the directory and did an npm install so that the gulp commands would work that generates ES5 modules. Anyway, to make the long story short, my build process was trying to build files from this new folder so I had to move it out of my root. This was causing these same errors.

Post Impatica
  • 10,585
  • 5
  • 48
  • 61