Error: Cannot find module './lib/compilers' with npm

Viewed 21

I had to install Nodejs/npm to debug and test some code, for some coding exercises in JavaScript.

But, when typing npm test filename.spec.js in my debugger terminal, the test did not launch.

I had the following output instead :

    Error: Cannot find module './lib/compilers'
Require stack:
- /home/tbatou/Téléchargements/javascript-exercises/node_modules/nanomatch/index.js
- /home/tbatou/Téléchargements/javascript-exercises/node_modules/sane/node_modules/micromatch/lib/compilers.js
- /home/tbatou/Téléchargements/javascript-exercises/node_modules/sane/node_modules/micromatch/index.js
- /home/tbatou/Téléchargements/javascript-exercises/node_modules/sane/node_modules/anymatch/index.js
- /home/tbatou/Téléchargements/javascript-exercises/node_modules/sane/src/common.js
- /home/tbatou/Téléchargements/javascript-exercises/node_modules/jest-haste-map/build/lib/WatchmanWatcher.js
- /home/tbatou/Téléchargements/javascript-exercises/node_modules/jest-haste-map/build/index.js
- /home/tbatou/Téléchargements/javascript-exercises/node_modules/jest-runtime/build/index.js
- /home/tbatou/Téléchargements/javascript-exercises/node_modules/@jest/core/build/cli/index.js
- /home/tbatou/Téléchargements/javascript-exercises/node_modules/@jest/core/build/jest.js
- /home/tbatou/Téléchargements/javascript-exercises/node_modules/jest/node_modules/jest-cli/build/cli/index.js
- /home/tbatou/Téléchargements/javascript-exercises/node_modules/jest/node_modules/jest-cli/bin/jest.js
- /home/tbatou/Téléchargements/javascript-exercises/node_modules/jest/bin/jest.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/tbatou/Téléchargements/javascript-exercises/node_modules/nanomatch/index.js:15:17)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1028:19)

(/Téléchargements (french) stands for /Downloads)

As I've encountered some with the similar issue, It was not with the same config/device neither with the same node module involved. Would anyone have a clue here ?

What I use

  • Ubuntu 22.04.1 LTS
  • GNOME 42.4
  • 64 Bits
  • npm version : 8.19.2
0 Answers
Related