Miguel Frias
Miguel Frias

Reputation: 2710

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.

Upvotes: 62

Views: 141440

Answers (30)

Danny Michaeli
Danny Michaeli

Reputation: 190

For me I just deleted both the package-lock.json file and the node_modules folder. Now everything works great πŸ˜ƒ

Upvotes: 3

user2280949
user2280949

Reputation: 77

have same problem, it works when i shutdown the Visual Studio Code thats open for that project

Upvotes: 0

DINA TAKLIT
DINA TAKLIT

Reputation: 8388

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"
  },

Upvotes: 0

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.

Upvotes: -1

iGotInTroubles
iGotInTroubles

Reputation: 1

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! :) ✌

Upvotes: 0

DrewT
DrewT

Reputation: 5072

The simplest fix for me was:

npm uninstall -g

Then:

npm install -g

Upvotes: 6

Kaumadie Kariyawasam
Kaumadie Kariyawasam

Reputation: 1456

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

npm install -g npm

it is working for me.

Upvotes: -1

leonel djatio
leonel djatio

Reputation: 1

Updating npm to latest version worked for me.

Upvotes: 0

dylan petrie
dylan petrie

Reputation: 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

    

Upvotes: -1

AMMAR YASIR
AMMAR YASIR

Reputation: 169

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

Upvotes: 0

BruceJo
BruceJo

Reputation: 771

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

Upvotes: 0

william007
william007

Reputation: 18525

These steps work for me:

    1. run "npm cache verify" or 
    2. remove node_modules and package-lock.json
and rerun command)

Upvotes: 1

Doctor
Doctor

Reputation: 7946

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

Upvotes: 1

serraosays
serraosays

Reputation: 7849

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.

Upvotes: 3

Subhadeep Chakraborty
Subhadeep Chakraborty

Reputation: 21

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

Upvotes: 2

robocon321
robocon321

Reputation: 409

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

Upvotes: 5

Anoushk
Anoushk

Reputation: 649

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

Upvotes: 1

Mahmmoud Kinawy
Mahmmoud Kinawy

Reputation: 881

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

Upvotes: 4

Samiron Barai
Samiron Barai

Reputation: 31

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

Upvotes: -1

Lellansin
Lellansin

Reputation: 912

This works for me,

rm -rf ./**/node_modules

while I need lerna bootstrap

Upvotes: -1

ANOOP NAYAK
ANOOP NAYAK

Reputation: 552

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.

Upvotes: 4

Jatin Kumar
Jatin Kumar

Reputation: 21

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...!

Upvotes: 2

Luis Gonzalez
Luis Gonzalez

Reputation: 111

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.

Upvotes: 1

Balaji Dharma
Balaji Dharma

Reputation: 1425

cache verify command resolved the issue for me

npm cache verify

Upvotes: 26

KushalSeth
KushalSeth

Reputation: 4629

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

Upvotes: 3

Michael Freidgeim
Michael Freidgeim

Reputation: 28425

I just retried to run

npm install 

and it succeeded

Upvotes: 3

S. Nadezhnyy
S. Nadezhnyy

Reputation: 582

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.

Upvotes: 0

xargr
xargr

Reputation: 3088

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

Upvotes: 97

Damo
Damo

Reputation: 6433

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.

Upvotes: 35

Miguel Frias
Miguel Frias

Reputation: 2710

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.

Upvotes: 3

Related Questions