Node.js/Windows error: ENOENT, stat 'C:\Users\RT\AppData\Roaming\npm'

269,544

Solution 1

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

More information can be found on Troubleshooting page

Solution 2

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.

Solution 3

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.

Solution 4

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.

Solution 5

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
Share:
269,544
tryasko
Author by

tryasko

Updated on April 20, 2020

Comments

  • tryasko
    tryasko about 4 years

    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?

    • skjagini
      skjagini over 9 years
      Try running the command prompt as administrator.
    • James Westgate
      James Westgate over 9 years
      Run command prompt as administrator, and create the folder.
    • codersaif
      codersaif almost 9 years
      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.
    • Frank Nocke
      Frank Nocke about 8 years
      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)
    • Natesh bhat
      Natesh bhat over 5 years
      My Unhandled event error got fixed in this answer stackoverflow.com/a/52441411/6665568
  • amcdnl
    amcdnl almost 10 years
    Seems like a bug on the instller.
  • Roman Starkov
    Roman Starkov over 9 years
    Is this bug in some tracker? This makes for an awful first experience with nodejs...
  • Sahas Katta
    Sahas Katta over 9 years
    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.
  • David Ebbo
    David Ebbo over 9 years
    It's being tracked by github.com/npm/npm/issues/5905, so you can subscribe to that issue to see progress.
  • maryo
    maryo over 9 years
    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.
  • Dnaso
    Dnaso over 9 years
    I logged in just to one up this.
  • Catalyst
    Catalyst over 9 years
    @Dnaso, same here -- still relevant to latest download
  • KFL
    KFL over 9 years
    I can confirm that this works on my laptop with 64bit Node, while the error reproduces on the Dell Venue with 32bit Node.
  • Chad
    Chad over 9 years
    For those who land here later, this is a reported issue at npm/npm#5905 and joyent/node#8117
  • Jonathan Livni
    Jonathan Livni over 9 years
    I would introduce such a bug just to get the >3K points for this answer on SO :)
  • ladieu
    ladieu over 9 years
    GREAT! Wow.. what a frustrating bug. Thanks for the easy fix
  • adam-p
    adam-p over 9 years
    I had to delete the existing npm directory and then re-create it.
  • Velter
    Velter over 9 years
    Had the same problem on Windows 7 64bit. Still not fixed. Maybe it has something to do with running cmd without admin rights?
  • robsn
    robsn over 9 years
    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'.
  • Aniket Thakur
    Aniket Thakur over 9 years
    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.
  • Sliq
    Sliq over 9 years
    btw 3 months later it's still not fixed :(
  • eran otzap
    eran otzap over 9 years
    still an issue on windows 7 and windows 8.1 , i always arrive here after installing node :)
  • Nate
    Nate over 9 years
    Same thing for me in Windows 10. Thanks for the tip.
  • Justin Russo
    Justin Russo over 9 years
    This is the only one that worked for me. Need to use -g for 'Global Mode' so it installs the packages into your <nodejs application path>. 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.
  • RyGuy
    RyGuy over 9 years
    This is the only solution that worked for me as well running Win 8.1 with the 64-bit installer. Thanks!
  • Dennkster
    Dennkster over 9 years
    This is the cleanest solution!
  • aliteralmind
    aliteralmind over 9 years
    @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?
  • maryo
    maryo about 9 years
    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\
  • Ed Sykes
    Ed Sykes about 9 years
    this also worked when hitting the same problem on OSX, albeit with a different file path
  • Vicky Zhang
    Vicky Zhang almost 9 years
    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...
  • torrao
    torrao about 8 years
    for me what worked was, manually create a '.npm_modules' folder, because I already had the 'npm' folder
  • Jens Stigaard
    Jens Stigaard about 8 years
    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.