14
  1. When I run npm start, I get this error message:

Error from chokidar (C:): Error: EBUSY: resource busy or locked, lstat 'C:\hiberfil.sys' Error from chokidar (C:): Error: EBUSY: resource busy or locked, lstat 'C:\pagefile.sys' Error from chokidar (C:): Error: EBUSY: resource busy or locked, lstat 'C:\swapfile.sys' Error from chokidar (C:\node_modules): Error: EBUSY: resource busy or locked, lstat 'C:\hiberfil.sys' Error from chokidar (C:\node_modules): Error: EBUSY: resource busy or locked, lstat 'C:\pagefile.sys' Error from chokidar (C:\node_modules): Error: EBUSY: resource busy or locked, lstat 'C:\swapfile.sys' Error from chokidar (C:\node_modules): Error: EBUSY: resource busy or locked, lstat 'C:\hiberfil.sys' Error from chokidar (C:\node_modules): Error: EBUSY: resource busy or locked, lstat 'C:\pagefile.sys' Error from chokidar (C:\node_modules): Error: EBUSY: resource busy or locked, lstat 'C:\swapfile.sys'

Shayan Shafiq
  • 1,447
  • 5
  • 18
  • 25
Vikram Shekhawat
  • 627
  • 2
  • 8
  • 12

13 Answers13

18

follow the below steps:

  1. Delete node_modules folder.
  2. run npm install .
  3. run npm cache clean .

*first 2 steps worked for me.
kartik tyagi
  • 6,256
  • 2
  • 14
  • 31
  • 3
    Thanks. The first two steps worked for me as well. – Tan Mar 10 '21 at 23:24
  • However, it started throwing same error again after I imported newly installed component in my code. And it is not going away even though I performed step 1 and 2 again. – Tan Mar 11 '21 at 23:53
  • The reason for the error thrown would majorly be caused by the use of an outdated versions of packages (dependencies). So, the best shot would be to follow the above 3 steps or upgrade every single dependency in the project (check inside package.json) – kartik tyagi May 10 '21 at 07:14
  • 2
    Yeah, I was missing some dependencies in package.json and it started working fine. Do you know why `npm cache clean` thorws this error `npm ERR! As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use 'npm cache verify' instead.` – Tan May 10 '21 at 22:13
  • There could be many reasons for that. It may occur due to npm didn't download properly, permission problem (try executing cmd with `sudo`), or It could be (most obiviously) due to not clearing cache properly (use `npm cache clean --force`) in that case. Also, the npm>5 have some upgrades, if you'll try removing and installing npm again, then this error may not occur. – kartik tyagi May 11 '21 at 23:58
  • Yeah, I had to use `npm cache clean --force` but whenever I checked the status using `npm verify` (I hope I wrote the command correctly), it always showed some 0MB bytes, even before running `npm cache clean --force`. I wonder if any cache is getting cleared or not. – Tan May 12 '21 at 03:39
3

Delete node_modules folder and then run:

npm install && npm clean-install react-scripts
Shayan Shafiq
  • 1,447
  • 5
  • 18
  • 25
Dohd
  • 359
  • 3
  • 7
2

I fixed this issue by installing the chart.js: 2.5.0 dependency. The issue with my code is that I was using react-chartjs-2 dependency and in order to use it, I needed to install chart.js.

Note that I had to install it manually. npm i wasn't working. Hope it helps.

Shayan Shafiq
  • 1,447
  • 5
  • 18
  • 25
Odair Vaz
  • 41
  • 1
  • 6
2

running

npm install --cache /tmp/empty-cache

Solves the problem for me.

2

I faced the same problem. Then I was importing a package that I didn't yet install. So make sure you have installed all the packages that you are using in the import statements at the top of your React component.

Shayan Shafiq
  • 1,447
  • 5
  • 18
  • 25
  • fair, I understand that, but wouldnt the error be higher up at all to where we could get more of a "cannot find module `x` in `index.js` etc"? Makes things hard to catch from an error perspective – Coty Embry Dec 18 '20 at 22:24
1

deleting node_modules folder and then running:

npm install
npm cache clean

worked for me!

1

I had the same problem with nativscript/angular router.

Problem was bad import. I mean deep import like @nativescript/angular/router.

I changed it to @nativescript/angular because there is no more deep imports.

Maybe it is a similar problem with your react-router.

Shayan Shafiq
  • 1,447
  • 5
  • 18
  • 25
quince
  • 165
  • 1
  • 11
1

I had the same issue. You're probably working in a Linux environment. If it is so, before running the start script, you need to switch the terminal to sudo user.

This approach fixed my issue.

Shayan Shafiq
  • 1,447
  • 5
  • 18
  • 25
0

Here are some things you can try to fix the error message:

  1. Delete all directories on C:\Users\<Username>\AppData\Local\Temp\ that start with npm-.
  2. npm cache clean
  3. Run as an administrator

Ref: npm Error : EBUSY resource busy or locked / npm | GitHub

karel
  • 5,489
  • 46
  • 45
  • 50
ABGR
  • 4,631
  • 4
  • 27
  • 49
0

Deleted all my node modules and reinstalled, worked for me

0

On Arch Linux just run:

rmdir -rf node_modules
sudo pacman -S npm
npm install -g semver
sudo pacman -Sy node-gyp
Lamech Desai
  • 709
  • 6
  • 11
0

Delete all node_modules and check npmrc file whether it's there in C:\Users<username> folder or not. If not, then create it and again do npm install followed by npm cache clean and npm run start.

Shayan Shafiq
  • 1,447
  • 5
  • 18
  • 25
0

I am using Yarn rather than npm

  1. Delete the node_modules folder
  2. yarn add
  3. npm cache verify
Paul Roub
  • 36,322
  • 27
  • 84
  • 93
azeem
  • 341
  • 3
  • 4