Coder Social home page Coder Social logo

[Bug]: error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. about ts-jest HOT 4 OPEN

zaininfo avatar zaininfo commented on June 2, 2024 7
[Bug]: error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.

from ts-jest.

Comments (4)

mike-lischke avatar mike-lischke commented on June 2, 2024 3

Would love to get a real solution. For now I suppress the import assertion error using:

// @ts-ignore, because when setting node module resolution to Node16, tsc raises an error for the import assertion.
import configSchema from "./config-schema.json" assert { type: "json" };

from ts-jest.

priley86 avatar priley86 commented on June 2, 2024

any update on this issue? Stumbling on it today 🙃

from ts-jest.

sezanzeb avatar sezanzeb commented on June 2, 2024

Try putting

	"extensionsToTreatAsEsm": [".ts"],
	"globals": {
		"ts-jest": {
			"useESM": true
		}
	}

into your jest.config, and set the NODE_OPTIONS=--experimental-vm-modules environment variable, or use node --experimental-vm-modules.

Also see #3525 and https://jestjs.io/docs/ecmascript-modules

from ts-jest.

sezanzeb avatar sezanzeb commented on June 2, 2024

(Or use vitest instead of jest https://vitest.dev/guide/migration.html#migrating-from-jest, which works for me without configuring anything at all)

from ts-jest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.