Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ts-jest[cli] (FATAL) Cannot find module 'jest-config' #758

Closed
mlynch opened this issue Sep 25, 2018 · 9 comments
Closed

ts-jest[cli] (FATAL) Cannot find module 'jest-config' #758

mlynch opened this issue Sep 25, 2018 · 9 comments

Comments

@mlynch
Copy link

mlynch commented Sep 25, 2018

Issue :

When following the automated install steps, the jest-config module cannot be found

npm install --save-dev jest ts-jest
npx ts-jest config:init

ts-jest[cli] (FATAL) Cannot find module 'jest-config'

Can confirm jest-config is installed in node_modules/

Expected behavior :

npx ts-jest config:init completes

@mlynch
Copy link
Author

mlynch commented Sep 25, 2018

Nevermind, had some old pinned jest and ts-jest versions from a copied over project. Works now!

@mlynch mlynch closed this as completed Sep 25, 2018
@pavvell
Copy link

pavvell commented Oct 6, 2018

I have the same issue with

jest: v21.0.2
ts-jest: v21.0.0

@mlynch what versions works for you?

@huafu
Copy link
Collaborator

huafu commented Oct 6, 2018

@pavvell this looks like very old version, can't you update jest and ts-jest to latest? I think latest jest is 23.6 and for ts-jest 23.10.4 just got published

@jktravis
Copy link

jktravis commented Nov 1, 2018

I'm in the process of upgrading to the latest version, and now I'm getting this error. The version I was using before ([email protected]) still works, though. Jest itself is now at 23.6.0.

@huafu
Copy link
Collaborator

huafu commented Nov 1, 2018

@jktravis this is usually reported by users who have some old version/artefacts remainings in their node_modules directory. The only deps related to jest/ts-jest which should be listed in your package.json should be: ts-jest, jest, typescript, @types/jest and maybe @types/node.

So I'd advise you to check that you have only this (related to jest, except if you have other pre-processors, but things like jest-cli or babel-jest should not be there). Then remove totally your node_modules folder and lock file, and yarn or npm install again.

@jktravis
Copy link

jktravis commented Nov 5, 2018

I did have babel-jest for some reason. I removed it, deleted my lock file, deleted node_modules and reinstalled with the upgraded version of ts-jest with the same result.

@mikew
Copy link

mikew commented Nov 6, 2018

Same here. Latest version of NPM, rm -rf node_modules/ && npm install results in jest-config living in node_modules/jest/node_modules/jest-config/

@huafu
Copy link
Collaborator

huafu commented Nov 8, 2018

#853 will be fixing this I think, I'll try to review it this Sun/Mon, tho #758 (comment) is still valid

@Christiangsn
Copy link

Christiangsn commented Oct 31, 2021

I managed to solve this problem like this:

my jest.config.ts to add
modulePaths: [ "<rootDir>", "/home/some/other/path" ], moduleDirectories: [ "node_modules" ],

adding this flag will probably solve your problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants