'"CHOKIDAR" error while working with Nodejs (MERN project)

Every time when i run or restart my backend server, it shows following error in my terminal:

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:\DumpStack.log.tmp'

My tech stack is: Nodejs, MongoDb, Mongoose, React, NPM, Material-ui If you still want to add me any code or file, let me know

Its pretty annoying, How can i eliminate this error?



Solution 1:[1]

Try this to solve your problem: 1- Delete node_modules folder. 2-run npm install . 3-run npm cache clean .

Solution 2:[2]

This problem happened to me after installing JSON-SERVER globally and watching the server. I'm not sure if that was the cause but it happened right after the watching started.

I aborted the watch and the app wouldn't load with npm run serve.

I tried everything suggested by every forum post I could find including deleting node_modules folder and package.json, npm install, cache clean, cache clean --force, resetting my computer, disabling anti-virus and I have no malware software installed.

The only thing that finally worked was creating a whole new project and copying and pasting the files from the old corrupt one into a new one. I also had to run npm install again so all the dependencies could be installed.

I don't understand why JSON Server should have anything to do with the cause unless the watching locks folders and renders the app unrunnable.

I will try again after I make a few copies of my app to experiment on because copying and pasting files is not a fun job unless your project is small enough.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ali ghanmi
Solution 2 David Agabi