ts-jest: [MODULE_NOT_FOUND] Error: ts-jest tried to access β¦, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
π Bug Report
When I add certain dependencies, I end up with a lot of errors like:
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access @typescript-eslint/eslint-plugin, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(Use `node --trace-warnings ...` to show where the warning was created)
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access @typescript-eslint/parser, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access clean-webpack-plugin, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access css-loader, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access eslint, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access eslint-config-airbnb-base, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access eslint-config-airbnb-typescript, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access eslint-config-prettier, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access eslint-import-resolver-node, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access eslint-loader, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access eslint-plugin-eslint-comments, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access eslint-plugin-import, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access eslint-plugin-jest, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access eslint-plugin-prettier, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access eslint-plugin-promise, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access eslint-plugin-unicorn, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access esm, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access html-loader, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access html-webpack-plugin, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access jest-cli, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access livereload, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access mini-css-extract-plugin, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access prettier, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access ts-loader, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access webpack, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:16644) [MODULE_NOT_FOUND] Error: ts-jest tried to access webpack-cli, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
This could be related to #1857 but I am not sure though.
To Reproduce
Steps to reproduce the behavior:
git clone https://github.com/alexkuc/ts-jest-yarn-2-bugyarn installyarn test
Expected behavior
Error [MODULE_NOT_FOUND] should not appear.
Link to repo (highly encouraged)
https://github.com/alexkuc/ts-jest-yarn-2-bug
Debug log:
{"context":{"allowJs":false,"logLevel":20,"namespace":"jest-preset","package":"ts-jest","version":"26.2.0"},"message":"creating jest presets not handling JavaScript files","sequence":1,"time":"2020-08-22T20:11:04.150Z"}
{"context":{"logLevel":20,"namespace":"Importer","package":"ts-jest","version":"26.2.0"},"message":"creating Importer singleton","sequence":2,"time":"2020-08-22T20:11:07.949Z"}
{"context":{"allowJs":false,"logLevel":20,"namespace":"jest-preset","package":"ts-jest","version":"26.2.0"},"message":"creating jest presets not handling JavaScript files","sequence":3,"time":"2020-08-22T20:11:07.968Z"}
{"context":{"actualVersion":"26.2.2","expectedVersion":">=26 <27","logLevel":20,"namespace":"versions","package":"ts-jest","version":"26.2.0"},"message":"checking version of jest: OK","sequence":4,"time":"2020-08-22T20:11:07.976Z"}
{"context":{"baseOptions":{},"logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformerId":1,"version":"26.2.0"},"message":"created new transformer","sequence":5,"time":"2020-08-22T20:11:07.976Z"}
{"context":{"fileName":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/fizzBuzz.test.ts","logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformOptions":{"config":{"automock":false,"cache":true,"cacheDirectory":"/private/var/folders/_p/292_lyvd0yg7dg7x9rqgldym0000gn/T/jest_dx","clearMocks":true,"coveragePathIgnorePatterns":["/node_modules/"],"cwd":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extraGlobals":[],"forceCoverageMatch":[],"globals":{"ts-jest":{"packageJson":"<rootDir>/package.json"}},"haste":{"computeSha1":false,"throwOnModuleCollision":false},"moduleDirectories":["node_modules"],"moduleFileExtensions":["js","json","jsx","ts","tsx","node"],"moduleNameMapper":[],"modulePathIgnorePatterns":[],"name":"cdfe7d1990277dc72edeb7b846199c52","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug","roots":["/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug"],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/.yarn/cache/jest-environment-jsdom-npm-26.2.0-493360024e-65198f8bc5.zip/node_modules/jest-environment-jsdom/build/index.js","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":["**/__tests__/**/*.[jt]s?(x)","**/?(*.)+(spec|test).[tj]s?(x)"],"testPathIgnorePatterns":["/node_modules/"],"testRegex":[],"testRunner":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/.yarn/cache/jest-jasmine2-npm-26.2.2-13dab4f95f-b4aa2bee7c.zip/node_modules/jest-jasmine2/build/index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/.yarn/$$virtual/ts-jest-virtual-2cfcad23f9/0/cache/ts-jest-npm-26.2.0-0a2029985b-79dcfa74af.zip/node_modules/ts-jest/dist/index.js",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"instrument":false,"rootDir":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug","supportsDynamicImport":false,"supportsStaticESM":false},"transformerId":1,"version":"26.2.0"},"message":"computing cache key for /Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/fizzBuzz.test.ts","sequence":6,"time":"2020-08-22T20:11:07.978Z"}
{"context":{"logLevel":30,"namespace":"jest-transformer","package":"ts-jest","transformerId":1,"version":"26.2.0"},"message":"no matching config-set found, creating a new one","sequence":7,"time":"2020-08-22T20:11:07.978Z"}
{"context":{"config":{"automock":false,"cache":true,"cacheDirectory":"/private/var/folders/_p/292_lyvd0yg7dg7x9rqgldym0000gn/T/jest_dx","clearMocks":true,"coveragePathIgnorePatterns":["/node_modules/"],"cwd":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extraGlobals":[],"forceCoverageMatch":[],"globals":{"ts-jest":{"packageJson":"<rootDir>/package.json"}},"haste":{"computeSha1":false,"throwOnModuleCollision":false},"moduleDirectories":["node_modules"],"moduleFileExtensions":["js","json","jsx","ts","tsx","node"],"moduleNameMapper":[],"modulePathIgnorePatterns":[],"name":"cdfe7d1990277dc72edeb7b846199c52","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug","roots":["/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug"],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/.yarn/cache/jest-environment-jsdom-npm-26.2.0-493360024e-65198f8bc5.zip/node_modules/jest-environment-jsdom/build/index.js","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":["**/__tests__/**/*.[jt]s?(x)","**/?(*.)+(spec|test).[tj]s?(x)"],"testPathIgnorePatterns":["/node_modules/"],"testRegex":[],"testRunner":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/.yarn/cache/jest-jasmine2-npm-26.2.2-13dab4f95f-b4aa2bee7c.zip/node_modules/jest-jasmine2/build/index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/.yarn/$$virtual/ts-jest-virtual-2cfcad23f9/0/cache/ts-jest-npm-26.2.0-0a2029985b-79dcfa74af.zip/node_modules/ts-jest/dist/index.js",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"logLevel":20,"namespace":"backports","package":"ts-jest","transformerId":1,"version":"26.2.0"},"message":"backporting config","sequence":8,"time":"2020-08-22T20:11:07.979Z"}
{"context":{"jestConfig":{"automock":false,"cache":true,"cacheDirectory":"/private/var/folders/_p/292_lyvd0yg7dg7x9rqgldym0000gn/T/jest_dx","clearMocks":true,"coveragePathIgnorePatterns":["/node_modules/"],"cwd":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extraGlobals":[],"forceCoverageMatch":[],"globals":{"ts-jest":{"packageJson":"<rootDir>/package.json"}},"haste":{"computeSha1":false,"throwOnModuleCollision":false},"moduleDirectories":["node_modules"],"moduleFileExtensions":["js","json","jsx","ts","tsx","node"],"moduleNameMapper":[],"modulePathIgnorePatterns":[],"name":"cdfe7d1990277dc72edeb7b846199c52","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug","roots":["/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug"],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/.yarn/cache/jest-environment-jsdom-npm-26.2.0-493360024e-65198f8bc5.zip/node_modules/jest-environment-jsdom/build/index.js","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":["**/__tests__/**/*.[jt]s?(x)","**/?(*.)+(spec|test).[tj]s?(x)"],"testPathIgnorePatterns":["/node_modules/"],"testRegex":[],"testRunner":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/.yarn/cache/jest-jasmine2-npm-26.2.2-13dab4f95f-b4aa2bee7c.zip/node_modules/jest-jasmine2/build/index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/.yarn/$$virtual/ts-jest-virtual-2cfcad23f9/0/cache/ts-jest-npm-26.2.0-0a2029985b-79dcfa74af.zip/node_modules/ts-jest/dist/index.js",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"version":"26.2.0"},"message":"normalized jest config","sequence":9,"time":"2020-08-22T20:11:07.979Z"}
{"context":{"fromPath":"<rootDir>/package.json","logLevel":20,"namespace":"config","package":"ts-jest","toPath":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/package.json","transformerId":1,"version":"26.2.0"},"message":"resolved path from <rootDir>/package.json to /Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/package.json","sequence":10,"time":"2020-08-22T20:11:07.980Z"}
{"context":{"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"tsJestConfig":{"compiler":"typescript","diagnostics":{"ignoreCodes":[6059,18002,18003],"pretty":true,"throws":true},"isolatedModules":false,"packageJson":{"kind":"file","value":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/package.json"},"transformers":{},"tsConfig":{"kind":"file"}},"version":"26.2.0"},"message":"normalized ts-jest config","sequence":11,"time":"2020-08-22T20:11:07.980Z"}
{"context":{"fromPath":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/package.json","logLevel":20,"namespace":"config","package":"ts-jest","toPath":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/package.json","transformerId":1,"version":"26.2.0"},"message":"resolved path from /Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/package.json to /Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/package.json","sequence":12,"time":"2020-08-22T20:11:07.982Z"}
{"context":{"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"version":"26.2.0"},"message":"babel is disabled","sequence":13,"time":"2020-08-22T20:11:08.036Z"}
{"context":{"logLevel":20,"namespace":"Importer","package":"ts-jest","requireResult":{"exists":true,"given":"typescript","path":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/.yarn/cache/typescript-patch-ba0dbfd217-f0d3d9c987.zip/node_modules/typescript/lib/typescript.js"},"version":"26.2.0"},"message":"loaded module typescript","sequence":14,"time":"2020-08-22T20:11:08.039Z"}
{"context":{"logLevel":20,"namespace":"Importer","package":"ts-jest","version":"26.2.0"},"message":"patching typescript","sequence":15,"time":"2020-08-22T20:11:08.043Z"}
{"context":{"actualVersion":"3.9.7","expectedVersion":">=3.8 <4","logLevel":20,"namespace":"versions","package":"ts-jest","version":"26.2.0"},"message":"checking version of typescript: OK","sequence":16,"time":"2020-08-22T20:11:08.045Z"}
{"context":{"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"tsconfig":{"compileOnSave":false,"configFileSpecs":{"includeSpecs":["**/*"],"validatedIncludeSpecs":["**/*"],"wildcardDirectories":{"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug":1}},"errors":[],"fileNames":["/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/fizzBuzz.test.ts","/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/fizzBuzz.ts"],"options":{"declaration":false,"inlineSourceMap":false,"inlineSources":true,"module":1,"noEmit":false,"removeComments":false,"sourceMap":true,"target":1},"raw":{"compileOnSave":false,"compilerOptions":{}},"typeAcquisition":{"enable":false,"exclude":[],"include":[]},"wildcardDirectories":{"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug":1}},"version":"26.2.0"},"message":"normalized typescript config","sequence":17,"time":"2020-08-22T20:11:08.055Z"}
{"context":{"fileName":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/fizzBuzz.ts","logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformOptions":{"config":{"automock":false,"cache":true,"cacheDirectory":"/private/var/folders/_p/292_lyvd0yg7dg7x9rqgldym0000gn/T/jest_dx","clearMocks":true,"coveragePathIgnorePatterns":["/node_modules/"],"cwd":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extraGlobals":[],"forceCoverageMatch":[],"globals":{"ts-jest":{"packageJson":"<rootDir>/package.json"}},"haste":{"computeSha1":false,"throwOnModuleCollision":false},"moduleDirectories":["node_modules"],"moduleFileExtensions":["js","json","jsx","ts","tsx","node"],"moduleNameMapper":[],"modulePathIgnorePatterns":[],"name":"cdfe7d1990277dc72edeb7b846199c52","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug","roots":["/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug"],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/.yarn/cache/jest-environment-jsdom-npm-26.2.0-493360024e-65198f8bc5.zip/node_modules/jest-environment-jsdom/build/index.js","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":["**/__tests__/**/*.[jt]s?(x)","**/?(*.)+(spec|test).[tj]s?(x)"],"testPathIgnorePatterns":["/node_modules/"],"testRegex":[],"testRunner":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/.yarn/cache/jest-jasmine2-npm-26.2.2-13dab4f95f-b4aa2bee7c.zip/node_modules/jest-jasmine2/build/index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/.yarn/$$virtual/ts-jest-virtual-2cfcad23f9/0/cache/ts-jest-npm-26.2.0-0a2029985b-79dcfa74af.zip/node_modules/ts-jest/dist/index.js",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"instrument":false,"rootDir":"/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug","supportsDynamicImport":false,"supportsStaticESM":false},"transformerId":1,"version":"26.2.0"},"message":"computing cache key for /Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/fizzBuzz.ts","sequence":18,"time":"2020-08-22T20:11:08.058Z"}
envinfo
System:
OS: OSX
Npm packages:
jest: 26.2.2
ts-jest: 26.2.0
typescript: 3.9.7
babel(optional): n/a
Edit: forgot to include errors
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20
Commits related to this issue
- fix(config): compute cache key without reading `package.json` (#1893) Closes #1892 — committed to kulshekhar/ts-jest by ahnpnl 4 years ago
yes I found that reading package.json to compute cache key isnβt necessary so removing it also makes sense.
I will use that as a fix for this issue.