question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:10

github_iconTop GitHub Comments

1reaction
sdkawatacommented, Jul 1, 2021

I had the same problem. Here is a minimal reproduction without typescript and ts-jest. https://github.com/sdkawata/11590

$ npx jest
Error: Cannot find module '@babel/traverse'
Require stack:
- /Users/kawata/11590/node_modules/jest-snapshot/build/InlineSnapshots.js
- /Users/kawata/11590/node_modules/jest-snapshot/build/State.js
- /Users/kawata/11590/node_modules/jest-snapshot/build/index.js
- /Users/kawata/11590/node_modules/jest-runtime/build/index.js
- /Users/kawata/11590/node_modules/@jest/core/build/cli/index.js
- /Users/kawata/11590/node_modules/@jest/core/build/jest.js
- /Users/kawata/11590/node_modules/jest/node_modules/jest-cli/build/cli/index.js
- /Users/kawata/11590/node_modules/jest/node_modules/jest-cli/bin/jest.js
- /Users/kawata/11590/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.<anonymous> (/Users/kawata/11590/node_modules/jest-snapshot/build/InlineSnapshots.js:146: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.<anonymous> (/Users/kawata/11590/node_modules/jest-snapshot/build/State.js:27:24)

tested 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

1reaction
ubansicommented, Jun 22, 2021

自分も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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot find module '@babel/traverse' · Issue #2674 - GitHub
Keep getting "Error: Cannot find module '@babel/traverse'" when running jest. Have installed the required packages and separately installed.
Read more >
@babel/traverse - npm
The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes. See our website @babel/traverse ......
Read more >
Cannot find module '@babel/core' - node.js - Stack Overflow
Try running this. npm install @babel/core --save. babel changed their package so your babel-core will not be the same as @babel/core .
Read more >
babel/traverse - Babel.js
We can use it alongside the babel parser to traverse and update nodes: import * as parser from "@babel/parser"; import traverse from "@babel/traverse"; ......
Read more >
Cannot find module '@babel/core' error [Solved] | bobbyhadz
To solve the error "Cannot find module '@babel/core'", make sure to install the @babe/core package by opening your terminal in your project's root...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found