seratch / notion-translator

CLI tool to translate Notion pages into a different language
MIT License
70 stars 20 forks source link

Error: ERR_REQUIRE_ESM #11

Closed mannipulator closed 11 months ago

mannipulator commented 11 months ago

Hello, I am trying to use your cool plugin, but I get this error while invoking the translate-command:

C:\Users\user1>notion-translator --from en --to id --url https://www.notion.so/mynotionsite
C:\Users\user1\AppData\Roaming\npm\node_modules\notion-translator\index.js:12
const open = require("open");
             ^

Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\user1\AppData\Roaming\npm\node_modules\notion-translator\node_modules\open\index.js from C:\Users\user1\AppData\Roaming\npm\node_modules\notion-translator\index.js not supported.
Instead change the require of C:\Users\user1\AppData\Roaming\npm\node_modules\notion-translator\node_modules\open\index.js in C:\Users\user1\AppData\Roaming\npm\node_modules\notion-translator\index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (C:\Users\user1\AppData\Roaming\npm\node_modules\notion-translator\index.js:12:14) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v20.8.0

I am using the newest version of the notion-translator package with a fresh install.

Any ideas how I can fix it?

Thank you ;)

seratch commented 11 months ago

Hi @mannipulator, thanks for taking the time to report this issue! It seems "open" package now supports only ESM. As a short-term workaround, I've downgraded the package to v8 and published a new version (0.0.7) with the change. Please try the latest version out!