-
Notifications
You must be signed in to change notification settings - Fork 97
Open
Description
Hello! Ran into an error running vitest on code that uses this library:
ReferenceError: exports is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '...\node_modules\@dsb-norge\vue-keycloak-js\package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
❯ ../node_modules/@dsb-norge/vue-keycloak-js/dist/dsb-vue-keycloak.cjs.js:4:29Error is due to package.json having type: module, indicating all .js files are ESM, and the file in main is CJS but ends in .js so is treated as ESM.
Solutions include removing type: module (or changing to type: commonjs), changing the file extension for the CJS bundle from .js to.cjs, or adding an exports field like so (current best practice):
"exports": {
".": {
"import": "./dist/dsb-vue-keycloak.es.js",
"require": "./dist/dsb-vue-keycloak.cjs.js",
"browser": "./dist/dsb-vue-keycloak.umd.js"
}
},Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels