score:0

i discovered a new situation,another possibility is an error during installation, reinstall ts-node to fix the problem

score:1

fyi this just happened to me at work. i'm not enough of an expert to understand what's going on under the hood, but the root of my problem was that i had my project running inside webpack in dev mode in a primary terminal, at the same time i was trying to run the tests in a 2nd terminal.

once i stopped the dev server, the tests ran just fine afterwards.

score:1

make sure to have:

moduledirectories: ["node_modules"]

not:

moduledirectories: ["/node_modules/"]

and don't omit the node_modules here.

score:2

i resolve the problem by running the project and node in the same drive.

i.e. previously my code is put in q:/ drive, and my nodejs is install in c:/ drive. and it keeps saying cannot find module 'source-map' from 'source-map-support.js' when i run jest.

once after i open my project in c:/, then it works.

score:5

hit this issue when using a jest test runner in vs code. taking a pointer from https://github.com/facebook/jest/issues/6880#issuecomment-441499110, i noticed that my jest.config.js contained

    moduledirectories: ["<rootdir>/node_modules", "<rootdir>/clientapp"]

changing it to

    moduledirectories: ["node_modules", "clientapp"]

fixed the problem.


Related Query

More Query from same tag