jest: typedoc throws "Cannot find module '@babel/types'." errors with jest 24
đź’Ą Regression Report
Running typedoc is fails with following errors after install jest 24. It works well with jest 23.
npx typedoc --out docs index.ts
Using TypeScript 3.2.4 from /Users/okuryu/work/tests/tests-20190326/node_modules/typescript/lib
Error: /Users/okuryu/work/tests/tests-20190326/node_modules/@types/babel__core/index.d.ts(12)
Cannot find module '@babel/types'.
Error: /Users/okuryu/work/tests/tests-20190326/node_modules/@types/babel__core/index.d.ts(13)
Cannot find module '@babel/parser'.
Error: /Users/okuryu/work/tests/tests-20190326/node_modules/@types/babel__generator/index.d.ts(8)
Cannot find module '@babel/types'.
Error: /Users/okuryu/work/tests/tests-20190326/node_modules/@types/babel__template/index.d.ts(8)
Cannot find module '@babel/parser'.
Error: /Users/okuryu/work/tests/tests-20190326/node_modules/@types/babel__template/index.d.ts(9)
Cannot find module '@babel/types'.
Error: /Users/okuryu/work/tests/tests-20190326/node_modules/@types/babel__traverse/index.d.ts(9)
Cannot find module '@babel/types'.
Error: /Users/okuryu/work/tests/tests-20190326/node_modules/@types/babel__traverse/index.d.ts(17)
Property 'scope' of type 'Scope' is not assignable to string index type '(VisitNodeFunction<S, any> & VisitNodeObject<S, any>) | (VisitNodeFunction<S, any> & VisitNodeFunction<S, any>) | (VisitNodeObject<S, any> & VisitNodeObject<S, any>) | (VisitNodeObject<...> & VisitNodeFunction<...>)'.
Error: /Users/okuryu/work/tests/tests-20190326/node_modules/@types/babel__traverse/index.d.ts(18)
Property 'noScope' of type 'boolean' is not assignable to string index type '(VisitNodeFunction<S, any> & VisitNodeObject<S, any>) | (VisitNodeFunction<S, any> & VisitNodeFunction<S, any>) | (VisitNodeObject<S, any> & VisitNodeObject<S, any>) | (VisitNodeObject<...> & VisitNodeFunction<...>)'.
Last working version
Worked up to version: ^23.0.0
Stopped working in version: ^24.0.0
To Reproduce
Steps to reproduce the behavior:
$ npm init -y
$ npm install --save-dev typedoc jest
$ npm ls jest typedoc
tests-20190326@1.0.0 /Users/okuryu/work/tests/tests-20190326
├── jest@24.5.0
└── typedoc@0.14.2
$ npx typedoc --out docs index.ts
index.ts
function main () {
}
Expected behavior
The typedoc works well.
Link to repl or repo (highly encouraged)
Please see the repro in “To Reproduce”.
Run npx envinfo --preset jest
Paste the results here:
System:
OS: macOS 10.14.3
CPU: (8) x64 Intel(R) Core(TM) i7-4750HQ CPU @ 2.00GHz
Binaries:
Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
Yarn: 1.13.0 - /usr/local/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v10.15.3/bin/npm
npmPackages:
jest: ^24.5.0 => 24.5.0
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 9
- Comments: 16 (4 by maintainers)
Commits related to this issue
- Set 'moduleResolution': 'node'. Workaround for https://github.com/facebook/jest/issues/8218 — committed to smockle/contrast by smockle 5 years ago
- Use node strategy for module resolution Fix facebook/jest#8218 error importing @babel/types. — committed to wimpyprogrammer/regex-to-strings by wimpyprogrammer 5 years ago
- Check TypeScript .d.ts files Use Node module resolution to avoid errors in Babel types per facebook/jest#8218. — committed to wimpyprogrammer/strings-to-regex by wimpyprogrammer 5 years ago
- Adds Jest and JSDoc, removes JQuery from `app.ts` **`.ci-jest/app.test.js` and `.ci-jest/view/audio.test.js`** - adds files to organize testing project via Jest **`README.md`** - adds attributi... — committed to S0AndS0/sensory-interface by S0AndS0 4 years ago
- Adds Jest and JSDoc, removes JQuery from `app.ts` **`.ci-jest/app.test.js` and `.ci-jest/view/audio.test.js`** - adds files to organize testing project via Jest **`README.md`** - adds attribution... — committed to S0AndS0/sensory-interface by S0AndS0 4 years ago
- Adds Jest and JSDoc, removes JQuery from `app.ts` **`.ci-jest/app.test.js` and `.ci-jest/view/audio.test.js`** - adds files to organize testing project via Jest **`README.md`** - adds attribution... — committed to S0AndS0/sensory-interface by S0AndS0 4 years ago
- Adds Jest and JSDoc, removes JQuery from `app.ts` **`.ci-jest/app.test.js` and `.ci-jest/view/audio.test.js`** - adds files to organize testing project via Jest **`README.md`** - adds attribution... — committed to S0AndS0/sensory-interface by S0AndS0 4 years ago
- Adds Jest and JSDoc, removes JQuery from `app.ts` **`.ci-jest/app.test.js` and `.ci-jest/view/audio.test.js`** - adds files to organize testing project via Jest **`README.md`** - adds attribution... — committed to S0AndS0/sensory-interface by S0AndS0 4 years ago
- Fix typescript compilation error Error message: Cannot find module @babel/types. https://github.com/facebook/jest/issues/8218#issuecomment-486275996 — committed to huy-nguyen/squarify by huy-nguyen 4 years ago
@okuryu what’s your tsconfig? I think I ran into problems like this because I forgot to set
"moduleResolution": "node"
at one pointOkay, this is a note for who have encountered the same error. I’m not sure which is the best way, but I confirmed that it works well by using three workarounds.
Option 1. put a small
tsconfig.json
file which have a"moduleResolution": "node"
optionOption 2. put default
tsconfig.json
filenote: The
moduleResolution
option of thetsconfig.json
seems to be commented out.Option 3. pass a
--moduleResolution node
option fortypedoc
like thisThis also works well to me.
@SimenB @brainkim Anyway, thanks a lot for your helps.
@brainkim Thanks for your suggestion!
Hmm, It certainly works when I put the following
tsconfig.json
file.Is this mean that I need this setting to use the typedoc and jest? I feel a little strange…
Hi,
I have this same error and found this issue when Googling for the string:
Property 'scope' of type 'Scope | undefined' is not assignable to string index type 'VisitNodeObject
As @okuryu suggests it looks like an issue with @types/babel__core
For me a temp fix is to just roll back to both v23:
npm i -D jest@23 babel-jest@23
I hope this helps other until the v24 issue is resolved.
Thanks.