'NPM: ENOENT: no such file or directory, rename
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: [email protected] (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.
Solution 1:[1]
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
Solution 2:[2]
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.
Solution 3:[3]
cache verify command resolved the issue for me
npm cache verify
Solution 4:[4]
I remove node_modules and package_lock.json. Then, npm install and it works
Solution 5:[5]
Iam using
-node v15.5.0
-npm v6.14.10
Try this:
- close "expo start"
- remove "package-lock.json"
- Try to install packages now
example: npm i @react-navigation/native
This will fix the issue.
Solution 6:[6]
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 installwith admin permission.
Solution 7:[7]
I just retried to run
npm install
and it succeeded
Solution 8:[8]
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
Solution 9:[9]
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
Solution 10:[10]
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...!
Solution 11:[11]
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.
Solution 12:[12]
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.
Solution 13:[13]
Just update the node to the latest version. It solved my problem.
Solution 14:[14]
I was running command in Ubuntu wsl and it wasn't working so i tried running in cmd prompt and it worked
Solution 15:[15]
Kindly check any package.json is open anywhere, then close it first then retry.
Solution 16:[16]
For me I just deleted both package-lock.json & node_modules folder. Now everything works great ?
Solution 17:[17]
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 installandyarn.
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.
Solution 18:[18]
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
Solution 19:[19]
These steps work for me:
1. run "npm cache verify" or
2. remove node_modules and package-lock.json
and rerun command)
Solution 20:[20]
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
Solution 21:[21]
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
Solution 22:[22]
Updating npm to latest version worked for me.
Solution 23:[23]
The simplest fix for me was:
npm uninstall -g
Then:
npm install -g
Solution 24:[24]
A combination of the answers from above worked for me:
- Restart the computer ( in my case WSL );
- Run the commands from bellow from your chosen terminal, not from VSCode terminal
- npm cache clean -f
- rm -rf node_modules
- rm package-lock.json
- npm install
Good luck! :) ?
Solution 25:[25]
This works for me,
rm -rf ./**/node_modules
while I need lerna bootstrap
Solution 26:[26]
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
Solution 27:[27]
Deleting package-lock.json or node_modules & After running:
npm install -g npm
it is working for me.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
