Project configuration
Closed this issue · 2 comments
vitaly-t commented
How one is supposed to configure the project to make this work?
I keep hitting this error:
const audic_1 = require("audic");
^
Error [ERR_REQUIRE_ESM]: require() of ES Module ...\node_modules\audic\dist\index.js from ...\src\analysis\strategies\pressure\index.js not supported.
Instead change the require of ...\node_modules\audic\dist\index.js in ...\src\analysis\strategies\pressure\index.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (C:\Projects\crypton-puro\src\analysis\strategies\pressure\index.js:10:17) {
code: 'ERR_REQUIRE_ESM'
}
Node.js v20.11.0
My tsconfig.json
file:
{
"compilerOptions": {
"target": "ES2022",
"module": "commonjs",
"moduleResolution": "node",
"resolveJsonModule": true,
"esModuleInterop": true,
"noUnusedLocals": true,
"baseUrl": "./"
},
"include": [
"./src/**/*.ts"
],
"exclude": [
"node_modules"
]
}
I do not use "type": "module"
in package, as it would break many other packages.
Richienb commented
https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
In summary, consider using const {default: Audic} = await import('audic');
vitaly-t commented
Thank you! Unfortunately, adding "type": "module"
creates so many problems with other packages...