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

[ERR_IMPORT_ASSERTION_TYPE_MISSING]: Module "[...]/tsconfig.json" needs an import assertion of type "json" #207

Open
kran6a opened this issue Apr 16, 2022 · 0 comments

Comments

@kran6a
Copy link

kran6a commented Apr 16, 2022

I am getting this error on node 17.9.0 when using tsconfig-paths from mocha through ts-node.

mocha command: mocha -n experimental-specifier-resolution=node -n loader=ts-node/esm --serial -p tsconfig.json --spec ./test/**/*.spec.ts

tsconfig.json:

{
	"extends": "./.svelte-kit/tsconfig.json",
	"compilerOptions": {
		"baseUrl": ".",
		"rootDir": ".",
		"module": "ESNext",
		"target": "ESNext",
		"lib": ["ESNext"],
		"typeRoots" : ["./node_modules/@types", "./src"],
		"sourceMap": true,
		"resolveJsonModule": true,
		"alwaysStrict": true
	},
	"typeAcquisition": {
		"enable": true
	},
	"ts-node": {
		"require": ["tsconfig-paths/register"],
		"compilerOptions": {
			"resolveJsonModule": true
		}
	},
	"paths": {
		"$src/*": ["src/*"],
		"$lib/*": ["src/lib/*"],
		"$api/*": ["src/routes/api/*"],
		"$app/*": [".svelte-kit/runtime/app/*"]
	}
}

Unfortunately no stack trace is shown so I don't know where the failing import is taking place but is should be as easy to fix as adding assert { type: 'json' } after the import like import tsconfig from './tsconfig.json' assert { type: 'json' };.

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

No branches or pull requests

1 participant