Cannot find module '@babel/traverse'
See original GitHub issue🐛 Bug Report
Keep getting “Error: Cannot find module ‘@babel/traverse’” when running jest.
Original report : https://github.com/kulshekhar/ts-jest/issues/2684
Have installed the required packages and separately installed. @babel/traverse which didn’t help either.
To Reproduce
Steps to reproduce the behavior:
if using package.json as belows ( using npm install -D typescript jest ts-jest @types/jest)
{ “devDependencies”: { “@types/jest”: “^26.0.23”, “jest”: “^27.0.4”, “ts-jest”: “^27.0.3”, “typescript”: “^4.3.3” } }
Expected behavior
run ts-jest
Link to repl or repo (highly encouraged)
https://github.com/bromix/typescript-jest-example
if using the following package.json, it works
“devDependencies”: { “@types/jest”: “^26.0.20”, “jest”: “^26.6.3”, “ts-jest”: “^26.4.4”, “typescript”: “^4.1.3” }
Debug log:
keep getting “Error: Cannot find module ‘@babel/traverse’” when running jest. node version v12.4.0
Error: Cannot find module ‘@babel/traverse’ Require stack:
/Users/external-contacts-hub/node_modules/jest-snapshot/build/InlineSnapshots.js /Users/external-contacts-hub/node_modules/jest-snapshot/build/State.js /Users//external-contacts-hub/node_modules/jest-snapshot/build/index.js /Users/external-contacts-hub/node_modules/jest-runtime/build/index.js /Users/external-contacts-hub/node_modules/@jest/core/build/cli/index.js /Users/external-contacts-hub/node_modules/@jest/core/build/jest.js /Users/external-contacts-hub/node_modules/jest/node_modules/jest-cli/build/cli/index.js /Users/external-contacts-hub/node_modules/jest/node_modules/jest-cli/bin/jest.js /Users/external-contacts-hub/node_modules/jest/bin/jest.js at Function.Module._resolveFilename (internal/modules/cjs/loader.js:623:15) at Function.resolve (internal/modules/cjs/helpers.js:21:19) at Object. (/Users/external-contacts-hub/node_modules/jest-snapshot/build/InlineSnapshots.js:72:17) at Module._compile (internal/modules/cjs/loader.js:774:30) at Object.Module._extensions…js (internal/modules/cjs/loader.js:785:10) at Module.load (internal/modules/cjs/loader.js:641:32) at Function.Module._load (internal/modules/cjs/loader.js:556:12) at Module.require (internal/modules/cjs/loader.js:681:19) at require (internal/modules/cjs/helpers.js:16:16) at Object. (/Users/external-contacts-hub/node_modules/jest-snapshot/build/State.js:13:24)
envinfo
System: OS: MacOs Big Sur Version 11.3.1 Node version: v12.4.0
Npm packages: jest: ts-jest: typescript: babel(optional):
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:10
Top GitHub Comments
I had the same problem. Here is a minimal reproduction without
typescript
andts-jest
. https://github.com/sdkawata/11590tested in OS: MacOs Catalina Version 10.15.7 Node version: v12.4.0
this problem does NOT occur in node v14.17.1 and v12.22.1
自分もnode v12.4.0で実行した場合同じ現象が発生しました。 nodeのバージョンをv14.17.1にアップデートした結果 問題は解決しました。
I had the same problem when running on node v12.4.0. As a result of updating the node version to v14.17.1 The problem has been solved.