3

I am facing an error when I am running npm commands for running a umi app project. This is the error I see when I run the code.

I have tried checking the node module for the loader.js file but I have not been able to find it.

internal/modules/cjs/loader.js:584
    throw err;
    ^

Error: Cannot find module '@nodelib/fs.stat'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
    at Function.Module._load (internal/modules/cjs/loader.js:508:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (C:\Users\cyhc9\umiapp\node_modules\fast-glob\out\adapters\fs-stream.js:17:14)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)

The code should run when I run npm commands or the project commands.

Caleb Yang
  • 83
  • 1
  • 12
  • `npm install @nodelib/fs.stat` try this once – Shubham Dixit May 22 '19 at 10:10
  • alternatively, completely remove your node_modules folder and run `npm i` again – BenSower May 22 '19 at 11:04
  • @shubh: Sure noted! – Caleb Yang May 22 '19 at 14:44
  • @BenSower: Sure! Thanks! – Caleb Yang May 22 '19 at 14:44
  • @shubh: I had such an error. The operation was rejected by your operating system. npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it. npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator (though this is not recommended). not sure if it is due to me cloning the repository from git etc. – Caleb Yang May 22 '19 at 16:08

1 Answers1

4

Possible solutions:

  1. Try not to have space in your directory name, i.e.: fun project/nestjs/..., try this: fun-project/nestjs/....
  2. Remove node_modules and package-lock.json then do npm install again to see if that solve the problem.
  3. Clear node cache by npm cache clean --force then repeat step number 2.
  4. Keep trying npm i again.
  5. Buy a new computer.

Good luck.

Mr. Dang
  • 535
  • 8
  • 14
  • 2
    Dang: That is very useful advice. Thanks for the commands. The new computer is out of budget for some developers so maybe customise or factory reboot the machine to run on more powerful windows with greater ram or ssd memory space. – Caleb Yang Aug 02 '20 at 03:26