Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ERR_REQUIRE_ESM #149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix ERR_REQUIRE_ESM #149

wants to merge 1 commit into from

Conversation

zhangsean
Copy link

@zhangsean zhangsean commented Mar 21, 2023

$ nrm
C:\Users\sean\AppData\Roaming\npm\node_modules\nrm\cli.js:9
const open = require('open');
             ^

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

Node.js v18.12.0

$ nrm ls
C:\Users\sean\AppData\Roaming\npm\node_modules\nrm\cli.js:9
const open = require('open');
             ^

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

Node.js v18.12.0
@LuoRiWuSheng
Copy link

$ nrm
C:\Users\sean\AppData\Roaming\npm\node_modules\nrm\cli.js:9
const open = require('open');
             ^

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

Node.js v18.12.0

你这个 ESM 和 CommonJS 2种规范 引入包, 应该是不行的

低版本的node 应该会报错

@LuoRiWuSheng
Copy link

LuoRiWuSheng commented Mar 24, 2023

我在我本地 调整了 包的 版本, lock 包的版本, npm link 调试了一下, 是没问题的
对应提交了一个 merge request #148

@zhangsean
Copy link
Author

期待新版本发布,我本地再试试!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants