allure-js
allure-js copied to clipboard
Failed to resolve "allure-vitest/reporter". This package is ESM only but it was tried to load by `require`.
Describe the bug
Failed to resolve "allure-vitest/reporter". This package is ESM only but it was tried to load by require
. See https://vitejs.dev/guide/troubleshooting.html#this-package-is-esm-only for more details. [plugin externalize-deps]
node_modules/esbuild/lib/main.js:1374:27:
1374 │ let result = await callback({
This error came from the "onResolve" callback registered here:
node_modules/esbuild/lib/main.js:1293:20:
1293 │ let promise = setup({
The plugin "externalize-deps" was triggered by this import
vitest.config.ts:1:332:
1 │ /vitest.config.ts";import AllureReporter from 'allure-vitest/reporter'
To Reproduce Steps to reproduce the behavior:
- npm install --save-dev allure-commandline
- npm install --save-dev allure-vitest
- npx vitest myTest.test.ts
Additional context
If you follow the link indicated in the error, they advise converting your config to ESM by either:
- adding "type": "module" to the nearest package.json
- renaming vite.config.js/vite.config.ts to vite.config.mjs/vite.config.mts
Is there another way to fix it?
Hey there!
Unfortunately, there is no way to use allure-vitest
outside an ESM module because the API provided by vitest
has esm
format, which isn't compatible with cjs
at all.
By the way, vitest
now prints a warning, that cjs
compatibility will be deprecated soon, so I don't know, is it reasonable to try to do something.