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

Package subpath "./presets" is not defined #2626

Closed
Verric opened this issue May 26, 2021 · 2 comments
Closed

Package subpath "./presets" is not defined #2626

Verric opened this issue May 26, 2021 · 2 comments

Comments

@Verric
Copy link

Verric commented May 26, 2021

💥 Regression Report

The error

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './presets' is not defined by "exports" in /Users/rich/dev/nebula/cloud/node_modules/ts-jest/package.json
    at throwExportsNotFound (internal/modules/esm/resolve.js:285:9)
    at packageExportsResolve (internal/modules/esm/resolve.js:491:3)
    at resolveExports (internal/modules/cjs/loader.js:444:36)
    at Function.Module._findPath (internal/modules/cjs/loader.js:484:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:818:27)
    at Function.Module._load (internal/modules/cjs/loader.js:687:27)
    at Module.require (internal/modules/cjs/loader.js:903:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/Users/rich/dev/nebula/cloud/jest.config.js:1:31)
    at Module._compile (internal/modules/cjs/loader.js:1015:30)

when I try to run my jest tests.

Last working version

26.1.1

Stopped working in version:
27.0.0

To Reproduce

Steps to reproduce the behaviour:
setup a jest.config.js with the following

const {defaults: tsjPreset} = require(`ts-jest/presets`)

module.exports = {
  displayName: `foo`,
  testEnvironment: `node`,
  transform: tsjPreset.transform,
  collectCoverage: false,
  testPathIgnorePatterns: [`.build`, `node_modules`, `.cache`, `dist`],
}

Expected behaviour

my tests to run :p

Link to repo (highly encouraged)

Debug log:

# content of ts-jest.log :
I don't even get this far...

envinfo

System:
    OS: Mac Catalina(10.15.7)

Npm packages:
    jest: 27.0.1
    ts-jest: 27.0.0
    typescript: 4.2.4
    babel(optional): N/A

Idk random notes.

So I didn't how to describe this issue so I just filed under regression, apologies if that's wrong.

So after some scrounging around, I believe the it maybe related to PR #2477
Particularly the amendments to the package.json#exports

  -  "./presets": "./jest-preset.js",
  +  "./jest-preset": "./jest-preset.js",
  + "./preset": "./presets/index.js",

Currently in my jest.config.js I import ts-jest via

const {defaults: tsjPreset} = require(`ts-jest/presets`)

as documented at: https://kulshekhar.github.io/ts-jest/docs/getting-started/presets/#advanced

I can see that essentially ./presets has been renamed to ./jest-presets
So I changed my import statements:

- const {defaults: tsjPreset} = require(`ts-jest/presets`)
+ const tsjPreset = require(`ts-jest/jest-preset`)

And it all works, so Idk if this was intended, if this is a breaking change, if the docs need to be changed or if I completely misunderstood something and got it working in some un-intended manner.

Apologies for the long winded post

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 26, 2021

duplicate #2623

@ahnpnl ahnpnl closed this as completed May 26, 2021
@Verric
Copy link
Author

Verric commented May 26, 2021

Man that was quick 👀
Apologies for the dupe post

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

No branches or pull requests

2 participants