3

I have just installed jest (npm install jest --save-dev) and not changed any default settings, but can't run my tests.

C:\Foo\Boo - my app folder, where app.js and app.test.js files are placed.

The standard command npm run test results in such error:

> vision@1.0.0 test C:\Foo\Boo
> jest

'Boo\node_modules\.bin\' is not recognized as an internal or external command,
operable program or batch file.
internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module 'C:\Foo\jest\bin\jest.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vision@1.0.0 test: `jest`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vision@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

A bizarre thing is Cannot find module 'C:\Foo\jest\bin\jest.js'. It seemingly trys to find C:\Foo\Boo\node_modules\jest\bin\jest.js.

How can I fix it?

Ilya Loskutov
  • 1,967
  • 2
  • 20
  • 34
  • whether you tried with the answers in this link https://stackoverflow.com/questions/50863312/jest-gives-cannot-find-module-when-importing-components-with-absolute-paths – Dinesh s Aug 26 '21 at 16:01

0 Answers0