ERR_REQUIRE_ESM
JonathanAmdahl opened this issue · 3 comments
JonathanAmdahl commented
Error [ERR_REQUIRE_ESM]: require() of ES Module /@invertase+node-paddle-sdk@0.3.3/node_modules/@invertase/node-paddle-sdk/dist/node-paddle-sdk.cjs.js
node-paddle-sdk.cjs.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename node-paddle-sdk.cjs.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /node_modules/.pnpm/@invertase+node-paddle-sdk@0.3.3/node_modules/@invertase/node-paddle-sdk/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
I was able to temporarily fix this by switching nodejs-paddle-sdk's module to commonjs
Ehesp commented
What node version are you running? I'll take a look soon, currently out of office
JonathanAmdahl commented
17.6.0
SchlagerKhan commented
I got it to work by patching the package such as:
- In
package.json
, remove the ".js" extension - In
dist
, rename thenode-paddle-sdk.cjs.js
tonode-paddle-sdk.cjs
(remove the.js
extension)
Done :)