Skip to content

[Bug]: ts-jest tried to access lodash, but it isn't declared in its dependencies #2977

@johngeorgewright

Description

@johngeorgewright

Version

27.0.6

Steps to reproduce

Try to use the latest release as per your instructions will result in an error:

ts-jest tried to access lodash, but it isn't declared in its dependencies

You can see this error thrown here:
https://github.com/johngeorgewright/plugola/runs/3904008362?check_suite_focus=true

The culprit seems to be this PR: #2959

The dependencies have been changed, but references to them have not. I assume it managed to pass tests as a the dev dependency tree still includes the full lodash package.

Expected behavior

Not to throw an error when using ts-jest.

Actual behavior

ts-jest throws an error when used as per instructions.

Debug log

➤ YN0000: Error: ts-jest tried to access lodash, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
➤ YN0000: 
➤ YN0000: Required package: lodash (via "lodash/memoize")
➤ YN0000: Required by: ts-jest@virtual:a58b2b25f01677cfb3a9cd4e4d274526187eb012964f52805295463a2665a7c1a12fb18addd3ceb966ef8873216da7d1c3d5f3b97dbf38238181ed7d83b87a9f#npm:27.0.6 (via /home/runner/work/plugola/plugola/.yarn/__virtual__/ts-jest-virtual-8f652c110d/0/cache/ts-jest-npm-27.0.6-bdc70f74ee-bbca6486a6.zip/node_modules/ts-jest/dist/compiler/)
➤ YN0000: 
➤ YN0000: Require stack:
➤ YN0000: - /home/runner/work/plugola/plugola/.yarn/__virtual__/ts-jest-virtual-8f652c110d/0/cache/ts-jest-npm-27.0.6-bdc70f74ee-bbca6486a6.zip/node_modules/ts-jest/dist/compiler/ts-compiler.js
➤ YN0000: - /home/runner/work/plugola/plugola/.yarn/__virtual__/ts-jest-virtual-8f652c110d/0/cache/ts-jest-npm-27.0.6-bdc70f74ee-bbca6486a6.zip/node_modules/ts-jest/dist/compiler/ts-jest-compiler.js
➤ YN0000: - /home/runner/work/plugola/plugola/.yarn/__virtual__/ts-jest-virtual-8f652c110d/0/cache/ts-jest-npm-27.0.6-bdc70f74ee-bbca6486a6.zip/node_modules/ts-jest/dist/ts-jest-transformer.js
➤ YN0000: - /home/runner/work/plugola/plugola/.yarn/__virtual__/ts-jest-virtual-8f652c110d/0/cache/ts-jest-npm-27.0.6-bdc70f74ee-bbca6486a6.zip/node_modules/ts-jest/dist/index.js
➤ YN0000: - /home/runner/work/plugola/plugola/.yarn/cache/jest-util-npm-27.2.5-5d02102daa-e57aaadac0.zip/node_modules/jest-util/build/requireOrImportModule.js
➤ YN0000: - /home/runner/work/plugola/plugola/.yarn/cache/jest-util-npm-27.2.5-5d02102daa-e57aaadac0.zip/node_modules/jest-util/build/index.js
➤ YN0000: - /home/runner/work/plugola/plugola/.yarn/__virtual__/jest-config-virtual-253c4900a2/0/cache/jest-config-npm-27.2.5-c2daeedc86-b3367bb65d.zip/node_modules/jest-config/build/getCacheDirectory.js
➤ YN0000: - /home/runner/work/plugola/plugola/.yarn/__virtual__/jest-config-virtual-253c4900a2/0/cache/jest-config-npm-27.2.5-c2daeedc86-b3367bb65d.zip/node_modules/jest-config/build/Defaults.js
➤ YN0000: - /home/runner/work/plugola/plugola/.yarn/__virtual__/jest-config-virtual-253c4900a2/0/cache/jest-config-npm-27.2.5-c2daeedc86-b3367bb65d.zip/node_modules/jest-config/build/normalize.js
➤ YN0000: - /home/runner/work/plugola/plugola/.yarn/__virtual__/jest-config-virtual-253c4900a2/0/cache/jest-config-npm-27.2.5-c2daeedc86-b3367bb65d.zip/node_modules/jest-config/build/index.js
➤ YN0000: - /home/runner/work/plugola/plugola/.yarn/__virtual__/jest-cli-virtual-ef0735f392/0/cache/jest-cli-npm-27.2.5-de57d01272-403468c466.zip/node_modules/jest-cli/build/init/index.js
➤ YN0000: - /home/runner/work/plugola/plugola/.yarn/__virtual__/jest-cli-virtual-ef0735f392/0/cache/jest-cli-npm-27.2.5-de57d01272-403468c466.zip/node_modules/jest-cli/build/cli/index.js
➤ YN0000: - /home/runner/work/plugola/plugola/.yarn/__virtual__/jest-cli-virtual-ef0735f392/0/cache/jest-cli-npm-27.2.5-de57d01272-403468c466.zip/node_modules/jest-cli/bin/jest.js
➤ YN0000: - /home/runner/work/plugola/plugola/.yarn/__virtual__/jest-virtual-127d5c83e9/0/cache/jest-npm-27.2.5-cc7147994b-fe26217165.zip/node_modules/jest/bin/jest.js
➤ YN0000:     at Function.external_module_.Module._resolveFilename (/home/runner/work/plugola/plugola/.pnp.cjs:23282:55)
➤ YN0000:     at Function.external_module_.Module._load (/home/runner/work/plugola/plugola/.pnp.cjs:23081:48)
➤ YN0000:     at Module.require (internal/modules/cjs/loader.js:974:19)
➤ YN0000:     at require (internal/modules/cjs/helpers.js:93:18)
➤ YN0000:     at Object.<anonymous> (/home/runner/work/plugola/plugola/.yarn/__virtual__/ts-jest-virtual-8f652c110d/0/cache/ts-jest-npm-27.0.6-bdc70f74ee-bbca6486a6.zip/node_modules/ts-jest/dist/compiler/ts-compiler.js:52:33)
➤ YN0000:     at Module._compile (internal/modules/cjs/loader.js:1085:14)
➤ YN0000:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
➤ YN0000:     at Module.load (internal/modules/cjs/loader.js:950:32)
➤ YN0000:     at Function.external_module_.Module._load (/home/runner/work/plugola/plugola/.pnp.cjs:23131:14)
➤ YN0000:     at Module.require (internal/modules/cjs/loader.js:974:19)

Additional context

No response

Environment

System:
    OS: macOS 10.15.7
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
  Binaries:
    Node: 12.22.7 - ~/.nvm/versions/node/v12.22.7/bin/node
    npm: 6.14.15 - ~/.nvm/versions/node/v12.22.7/bin/npm
  npmPackages:
    jest: ^27.1.1 => 27.2.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions