'Npm ERR! code EPERM

I'm using node v6.11.2, npm v5.3.0 and angular/cli v1.2.7.

I'm suddenly receiving the following error message for a majority of my npm installs. Never seen it before...

mmeppiel@MC-LT-MMEPPIEL MINGW64 ~/Desktop/Angular Solutions/my-app (master)
$ npm install --save [email protected] font-awesome
npm ERR! path C:\Users\mmeppiel\Desktop\Angular Solutions\my-app\node_modules\fs                            events\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall lstat
npm ERR! Error: EPERM: operation not permitted, lstat 'C:\Users\mmeppiel\Desktop                            \Angular Solutions\my-app\node_modules\fsevents\node_modules'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, lstat 'C:\Users\mmeppiel\Desk                            top\Angular Solutions\my-app\node_modules\fsevents\node_modules'
npm ERR!     at Error (native)
npm ERR!   stack: 'Error: EPERM: operation not permitted, lstat \'C:\\Users\\mme                            ppiel\\Desktop\\Angular Solutions\\my-app\\node_modules\\fsevents\\node_modules\                            '\n    at Error (native)',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'lstat',
npm ERR!   path: 'C:\\Users\\mmeppiel\\Desktop\\Angular Solutions\\my-app\\node_                            modules\\fsevents\\node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\mmeppiel\AppData\Roaming\npm-cache\_logs\2017-08-08T00_56_                            59_442Z-debug.log

Can anyone explain what's going on here? Things I've tried:

  • Running Git Bash as an administrator
  • Turning off my firewall and AntiVirus protections
  • Running npm cache clean
  • Manually deleting the contest of AppData\Roaming\npm-cache
  • Uninstalling node via the Control Panel and reinstalling
  • Gave Everyone full permissions to C:\Program Files\nodejs
  • Reinstalled the CLI
  • Restarted my computer (can't hurt?)
  • Made sure the node_modules folder is not read only

Appreciate your time!



Solution 1:[1]

Are you using any private or company registry. check your .npmrc file and make sure its available.

if you are in company environment, make sure proxy is not a problem.

check in your folder if any package-lock.json is generated. you can delete that make re install.

I have little doubt but node 6.x.x with npm 5.x.x might be a problem as node 7.x.x is compatible arable with 5.x.x. And normally node 6.x.x is compatible with npm 4.x.x

Solution 2:[2]

I get this error when running Visual Studio Code because the typescript compiler watches files and locks them (see https://github.com/Microsoft/vscode/issues/28593). The solution is to temporarily close VS Code when dealing with NPM. Perhaps you have something watching files?

Solution 3:[3]

I'm having the same problem, even using Node v8.6.0 and npm v5.4.2.

Solved with:

npm cache clean --force

&

npm install [package] --force

Reference: npm wiki's troubleshooting guide.

Solution 4:[4]

This might help https://alastaircrabtree.com/fixing-intermittant-eperm-operation-not-permitted-on-npm-install/

Also try to play with different node versions the best way of upgrading/switching your node on Windows is to use nvm-windows this way you can have multiple node versions installed on your dev machine you can switch across.

UPDATE 0:

When you dealing with such a problems you have to make sure that nothing is locking our node_modules folder like your Code Editor(e.g VS Code, ect) or you might be running npm start in another console window, etc

UPDATE 1:

If you still experiencing the issue try completely to uninstall both node and npm from your system. Then restart your machine and install node and npm again.

HOWEVER

It is seams like it is common issue by looking in to the npm issues filtering by npm ERR! code EPERM. If you browse some of these issues you will see that some people saying that switching the node version is actually help(exactly I was saying at first above) so you need to play with nvm-windows and see what node version is working best for you.

Once you have nvm-windows installed you can do:

  • nvm list - shows all your local node versions you can switch to
  • nvm list available - shows all actual node versions that you can install locally
  • nvm install <version number> - install(download+install) a particular node version
  • nvm use <version number> switch to particular node version
  • nvm help - will give you help

If you jump from major version of npm some of your packages that you installed with a previous node version might no longer work so you have to be reinstall them

Solution 5:[5]

Run windows command prompt as administrator. Then navigate ("cd directoryName")to your project folder do "npm install".

Solution 6:[6]

Resolved this by installing typescript globally. The Angular Compiler requires TypeScript >=3.1.1 and <3.3.0 Changed the version in the package.json to the installed version. Then did an npm install

    npm install -g typescript
    npm info typescript version
    npm install

Solution 7:[7]

I had the same problem while using the VS CODE Terminal, you can open cmd, or bash as administrator or root and then just npm install (your package)

Solution 8:[8]

Very similar problem, only the specific complaint was that scandir was failing on a certain subfolder (fsevents) in the new app's target directory. I checked and found that the folder in question did not even exist because it was the product of an optional dependency which was skipped on npm install because I was on Windows and not Linux.

The script running the app build command runs in such a way to compensate for this when "ng new " is run under Windows PowerShell. It does not work when run in an ordinary cmd window. So in my case the fix was simply to run "ng new under Windows PowerShell instead of in a cmd window and the install completed successfully -- finally, after having tried several other things.

Solution 9:[9]

Normally we assume that "tns run android" command will also setup the android plateform, which failed for me two times and then I resolved it by running the following two commands in the given order:

   tns platform add android
   tns run android

Solution 10:[10]

Try running command prompt as administrator. Worked for me.

Solution 11:[11]

Usually its because of no permission to access the folders inside C:/Users/... If you have created your project in the C:/Users/.. folder, you need to get administrative permission to make changes to that folder. Run your Code Editor As Administrator. This will allow the program to make changes to that folder.

Solution 12:[12]

SOLUTION SPECIFIC FOR ANGULAR APPLICATION

Turn off your angular compiler (ie. ng serve) & again try to install the package

Works for me every time.

Solution 13:[13]

I faced this problem when I went to install the react-rating package. I just switched from npm to yarn and it was solved.

That means instead of npm install --save react-rating I used yarn add react-rating

Solution 14:[14]

If you have it in gatsby.js. I had problem with timeouts. This fixed it, you should add it to envs:

CONNECTION_TIMEOUT=600000
STALL_RETRY_LIMIT=10
STALL_TIMEOUT=60000
GATSBY_CONCURRENT_DOWNLOAD=1

Solution 15:[15]

I had the same problem. I delete the package-lock.json and rerun npm install again. Problem solved.

Solution 16:[16]

The problem is you're on the incorrect version of node for your operating system. It's trying to fetch lstat (a POSIX syscall) which doesn't exist on Windows.

Currently I do not have a solution other than install the correct npm

Hopefully this helped you !

https://linux.die.net/man/2/lstat

EDIT If you can't find a fix i'd suggest for you to go to the Github Issue page.

Solution 17:[17]

It might be the most basic solution, but an EPERM error can be resolved only by giving permission.

  1. Deactivate any anti-virus software (until complete install) that there are on your PC.

  2. Make sure that the adb.exe file (if there is) is not running on the background.

    To do this, open the task manager, go to the 'Processes' tab and end the adb.exe process.

  3. Uninstall incomplete previous installs of expo-cli by running the command

    npm uninstall -g expo-cli --save

  4. Now, install the expo-cli app

    npm install -g expo-cli

This has done the trick in my case. Might do for somebody else as well.

Cheers!

Solution 18:[18]

Delete node modules and run npm cache clean --force

Then run,

npm install --save

Worked for me