59

I was using gulp on the project, then i decide to deleted all the dev dependencies to switch to webpack, but every time i try to install using npm is get this error:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename 'C:\Users\MiguelFrias\Desktop\Therabytes\node_modules\.staging\fsevents-e80c4ef4\node_modules\are-we-there-yet' -> 'C:\Users\MiguelFrias\Desktop\Therabytes\node_modules\.staging\are-we-there-yet-5db4c798'

npm ERR! path C:\Users\MiguelFrias\Desktop\Therabytes\node_modules\acorn
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\MiguelFrias\Desktop\Therabytes\node_modules\acorn' -> 'C:\Users\MiguelFrias\Desktop\Therabytes\node_modules\.acorn.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\MiguelFrias\AppData\Roaming\npm-cache\_logs\2018-04-04T11_54_23_587Z-debug.log

any idea what can be happening.

Miguel Frias
  • 2,544
  • 8
  • 32
  • 53
  • 3
    Got something very similar to this when trying to install Express in a folder that was in Dropbox. So instead I installed it to a temp folder outside Dropbox, and copied it in, and this solved my problem. Pretty annoying tho. – Kebman Jul 09 '21 at 06:02
  • 2
    @kebman : after trying a number of suggestions you saved my day: dropbox,,,, – Ad Gerrits Sep 05 '21 at 20:32

31 Answers31

92

just delete package-lock.json file and then install packages, that's all you need and should be works

rm package-lock.json && npm i
xargr
  • 2,788
  • 1
  • 19
  • 28
34

When I got this error I looked for all running instances of node in my task manager (i use process explorer on windows) and close/kill all running instances of node. For me its often webstorm or vs code. After closing these programs and ensuring there is no running node process npm install works again.

Damo
  • 5,698
  • 3
  • 37
  • 55
21

cache verify command resolved the issue for me

npm cache verify
Balaji D
  • 1,245
  • 13
  • 20
  • 1
    This worked for me after 2 days of struggling with this error. Thanks – Akshay Antony Mar 21 '22 at 09:58
  • 1
    Running the above command worked for me. However, a prompt came to run sudo chown -R 501:20 "" . After this I ran npm install and it worked fine. My node version v19.9.0 and npm 9.6.3. – Emmanuel R Apr 23 '23 at 23:18
  • I was trying to install Bootstrap and that command helped (then I realized another error told me to mkdir manually so probably this is what helped more) – Dominika Wojewska Aug 20 '23 at 20:19
5

The simplest fix for me was:

npm uninstall -g

Then:

npm install -g
DrewT
  • 4,983
  • 2
  • 40
  • 53
4

I remove node_modules and package_lock.json. Then, npm install and it works

robocon321
  • 363
  • 5
  • 8
3

Iam using
-node v15.5.0

-npm v6.14.10

Try this:

  1. close "expo start"
  2. remove "package-lock.json"
  3. Try to install packages now

example: npm i @react-navigation/native

This will fix the issue.

ANOOP NAYAK
  • 473
  • 5
  • 8
2

The second line may give a hint on what's happening:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename 'C:\Users\MiguelFrias\Desktop\Therabytes\node_modules\.staging\fsevents-e80c4ef4\node_modules\are-we-there-yet' -> 'C:\Users\MiguelFrias\Desktop\Therabytes\node_modules\.staging\are-we-there-yet-5db4c798'

It looks like npm doesn't have enough permission on the folder you're trying to use.

You can try:

  • Delete the npm_modules again.
  • Open whatever editor/terminal you're using to npm install with admin permission.
Gustavo Lopes
  • 3,794
  • 4
  • 17
  • 57
  • Im using commander (Cmder), i already try with deleting the node_modules and run terminal as a admin but still happening the same – Miguel Frias Apr 04 '18 at 13:38
2

I found a solution for the problem, apparently is some kinda problem with the last version of npm, i was using npm version 5.6.0 and i downgraded to npm version 5.3.0. This did work after all, after intall a couple packages i still get the same error.

ok change version of npm for the last version 5.8.0 now everything working just perfect, before was some kind of problem with atom that denied the permission the building process to install the dependencies of the package.

Miguel Frias
  • 2,544
  • 8
  • 32
  • 53
2

I just retried to run

npm install 

and it succeeded

Michael Freidgeim
  • 26,542
  • 16
  • 152
  • 170
2

For me, package-lock.json was not created and script was failing before itself.

This fixed my issue:

- deleted my node_modules.
- npm cache clean 
- opened cmd as administrator at the repository folder
- logged-in to the https://registry.npmjs.org/ using username and passoward as few of my components needed authentication to install.
- npm i

KushalSeth
  • 3,265
  • 1
  • 26
  • 29
2

If you ever get this error, the hotfix is to follow these steps:

delete node-modules folder run command npm cache clean --force run command npm install install the package again with npm install your-package-name

Mahmmoud Kinawy
  • 551
  • 4
  • 11
1

Actually the current package you are installing has some dependencies which is not being found my npm. So, before installing this package just perform the following command. (It will install all your listed dependencies mentioned in package.json file which are necesaary to run your application)

npm install 

It works...!

0

For not to delete package-lock.json or node_modules every time, just add file ".npmrc" with content "package-lock=false", or add this string if file ".npmrc" already exists.

S. Nadezhnyy
  • 582
  • 2
  • 6
0

You can try by removing the package-lock.json with the command rm package-lock.json then you go to the Node.JS website you 'install it' by going to LTS then after your node is updated run npm install in your terminal and that worked for me.

0

I was running command in Ubuntu wsl and it wasn't working so i tried running in cmd prompt and it worked

Anoushk
  • 551
  • 7
  • 20
0

Kindly check any package.json is open anywhere, then close it first then retry.

  • Please provide additional details in your answer. As it's currently written, it's hard to understand your solution. – Community Sep 02 '21 at 08:05
0

For me I just deleted both package-lock.json & node_modules folder. Now everything works great

0

Another thing I've seen a lot on projects that have been around and gone through multiple contributors:

  • Double check to see if anyone on your team has simultaneously done a npm install and yarn.

The tell-tale sign is you'll see a package-lock.json (generated by npm) and yarn-lock.json (generated by yarn) in the same repo. This can cause side-effects from collisions in the node_modules folder.

You can try dumping that folder locally, establishing a package manager of choice for your project and instructing the whole team on best practices.

serraosays
  • 7,163
  • 3
  • 35
  • 60
0

For me I had to sudo the npm install command. Don't know why... Don't want to know either.

sudo npm install --save-dev my_package
Doctor
  • 7,115
  • 4
  • 37
  • 55
0

These steps work for me:

    1. run "npm cache verify" or 
    2. remove node_modules and package-lock.json
and rerun command)
william007
  • 17,375
  • 25
  • 118
  • 194
0

Sometimes it can be the fault of the package you are trying to install. If that package is a local package and has a node_modules folder. Try:

cd /path/to/package
rm -rf package-lock.json npm-shrinkwrap
npm install
BruceJo
  • 591
  • 6
  • 17
0

Happen to me when I was coding react native app with expo, when I was run the app and try to install form npm happen that error. So just stop run the app and reinstall the package for me it work fine

AMMAR YASIR
  • 161
  • 1
  • 8
0

Updating npm to latest version worked for me.

0

A combination of the answers from above worked for me:

  1. Restart the computer ( in my case WSL );
  2. Run the commands from bellow from your chosen terminal, not from VSCode terminal
  3. npm cache clean -f
  4. rm -rf node_modules
  5. rm package-lock.json
  6. npm install

Good luck! :) ✌

0

I got the same issue when I wanted to deploy my react app to github pages after running npm run deploy I go the error

npm build error enoent: no such file or directory, stat '/users/user/desktop/projects/properties/client/build'

I figure out that I forgot to add predeploy script, after adding it things worked perfectly

"scripts": {
    "dev": "refine start",
    "build": "refine build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "refine": "refine",
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build"
  },
DINA TAKLIT
  • 7,074
  • 10
  • 69
  • 74
-1

Deleting package-lock.json or node_modules & After running:

npm install -g npm

it is working for me.

Kaumadie Kariyawasam
  • 1,232
  • 3
  • 17
  • 35
-1

This works for me,

rm -rf ./**/node_modules

while I need lerna bootstrap

Lellansin
  • 852
  • 1
  • 9
  • 15
-1

Just update the node to the latest version. It solved my problem.

-1

This worked for me (on command line in Ubuntu): Update Node using

sudo npm install -g n 

followed by

sudo n 16.13.2

Closed and reopened shell, cd back into the correct repo and then

sudo install npm -g

    
Andrew
  • 2,046
  • 1
  • 24
  • 37
-1

Dont run cmd in root of a directory. there might be one directory inside which u try to run. cd Directory npm i

Harsh
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 12 '22 at 15:33
-1

In may case, it was next-i18next.config.js, that had duplicated languages in the locales value, and fallbackLng with existing languages refer to existing languages.