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

[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. #1892

Closed
alexkuc opened this issue Aug 22, 2020 · 20 comments Β· Fixed by #1893
Labels

Comments

@alexkuc
Copy link

alexkuc commented Aug 22, 2020

πŸ› 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:

  1. git clone https://github.com/alexkuc/ts-jest-yarn-2-bug
  2. yarn install
  3. yarn 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

@alexkuc alexkuc added Bug Report Needs Repo Need a minimium repository to reproduce the problem Needs Triage labels Aug 22, 2020
@ahnpnl
Copy link
Collaborator

ahnpnl commented Aug 22, 2020

it looks to me like lodash ?

@alexkuc
Copy link
Author

alexkuc commented Aug 22, 2020

My apologies! Forgot to include errors. I don't use lodash for this particular repo.

(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.

@ahnpnl
Copy link
Collaborator

ahnpnl commented Aug 22, 2020

hmm looking at those dependencies, only a few eslint dependencies are used in the codebase. But those deps are devs and not used for production code. The rest of dependencies are not related to ts-jest. I think the error comes from somewhere else, I don't think it's ts-jest issue.

Not sure what yarn 2 is trying to do

@ahnpnl
Copy link
Collaborator

ahnpnl commented Aug 22, 2020

something similar is reported here yarnpkg/berry#1599

@alexkuc
Copy link
Author

alexkuc commented Aug 22, 2020

I also believe that error should originate from somewhere else. But I am having a hard time pinpointing the root cause. And the fact that ts-jest tried to access is logged is somewhat misleading to me too.

For example,

  "devDependencies": {
    "@types/jest": "^26.0.8",
    "jest": "^26.2.2",
    "jest-cli": "^26.4.2",
    "ts-jest": "26.2.0",
    "typescript": "^3.9.7"
  },

generates error:

(node:17086) [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.

So in this case, adding jest-cli leads to [MODULE_NOT_FOUND] error.

@ahnpnl
Copy link
Collaborator

ahnpnl commented Aug 22, 2020

in the reference link, you can see there is a comment also saying when running jest. I don't think in this case ts-jest can do anything about it, it's a different case than #1857

@alexkuc
Copy link
Author

alexkuc commented Aug 22, 2020

What about other cases, like these ones? Do you think they are also caused by @types?

(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.

or

(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.

@ahnpnl
Copy link
Collaborator

ahnpnl commented Aug 22, 2020

I suspect the @types package too like the issue reported by yarn. The whole yarn 2 is not wildly adopted yet so I think there will be still more things undiscovered.

@alexkuc
Copy link
Author

alexkuc commented Aug 22, 2020

What do you think about this?

ts-jest-yarn-2-bug $ NODE_OPTIONS=--trace-warnings yarn test
(node:17445) [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.
    at internalTools_makeError (/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/.pnp.js:9533:34)
    at resolveToUnqualified (/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/.pnp.js:10466:21)
    at resolveRequest (/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/.pnp.js:10552:29)
    at Object.resolveRequest (/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/.pnp.js:10618:26)
    at Function.external_module_.Module._resolveFilename (/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/.pnp.js:9765:34)
    at Function.external_module_.Module._load (/Users/alexkucheryuk/Repositories/GitHub/ts-jest-yarn-2-bug/.pnp.js:9629:48)
    at Module.require (internal/modules/cjs/loader.js:1140:19)
    at require (internal/modules/cjs/helpers.js:75:18)
    at Object.getPackageVersion (/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/util/get-package-version.js:6:16)
    at /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/config/config-set.js:177:53

Specifically, this line:

    at /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/config/config-set.js:177:53

@ahnpnl
Copy link
Collaborator

ahnpnl commented Aug 22, 2020

hmm that line is about reading package.json to get versions from dependencies, devDependencies, peerDependencies, optionalDependencies to construct cacheKey for jest. Not sure why ts-jest takes into account of project dependencies to construct cache key, maybe it is not needed.

I suspect the stacktrace is related to this https://github.com/kulshekhar/ts-jest/blob/master/src/util/get-package-version.ts#L6

@alexkuc
Copy link
Author

alexkuc commented Aug 22, 2020

I think webpack complains about this line, specifically method getPackageVersion.

@ahnpnl
Copy link
Collaborator

ahnpnl commented Aug 22, 2020

can you please try with this https://drive.google.com/file/d/1IzNZWnmuz4DblvadhMVpnZlQwWRwtc_W/view?usp=sharing ?
I removed the method to read package.json for computing cache key

@alexkuc
Copy link
Author

alexkuc commented Aug 22, 2020

How do I get it working? I tried installing dependencies but keep getting errors. Is it meant to be used as a patch? Or as standalone?

Error: Cannot find module '/Users/alexkucheryuk/Downloads/ts-jest/scripts/clean-dist.js'

@ahnpnl
Copy link
Collaborator

ahnpnl commented Aug 22, 2020

you can modify your project package.json like this

// other dependencies
"ts-jest": "./ts-jest-26.2.10-alpha.0.tgz",

then run yarn install. After that clear cache and rerun test

@alexkuc
Copy link
Author

alexkuc commented Aug 22, 2020

I think it looks good now. I don't get no more [MODULE_NOT_FOUND] errors.

@ahnpnl
Copy link
Collaborator

ahnpnl commented Aug 22, 2020

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.

@ahnpnl ahnpnl added πŸ› Bug Confirmed Bug is confirmed and removed Bug Report Needs Repo Need a minimium repository to reproduce the problem Needs Triage labels Aug 22, 2020
@alexkuc
Copy link
Author

alexkuc commented Aug 22, 2020

Thank you very much for being so pro-active and helping me with the issue! Greatly appreciated! πŸš€

@alexkuc
Copy link
Author

alexkuc commented Aug 24, 2020

@ahnpnl do you know when next release will be available on npmjs?

@ahnpnl
Copy link
Collaborator

ahnpnl commented Aug 24, 2020

hi, somewhere this week :)

@alexkuc
Copy link
Author

alexkuc commented Aug 24, 2020

AWesome, cheers! :)

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

Successfully merging a pull request may close this issue.

2 participants