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

node: imports aren't supported in Node.js v14 #1867

Closed
electerious opened this issue Jul 22, 2022 · 4 comments · Fixed by #1874
Closed

node: imports aren't supported in Node.js v14 #1867

electerious opened this issue Jul 22, 2022 · 4 comments · Fixed by #1874

Comments

@electerious
Copy link

The rule.js file uses node: imports which are supported since Node.js v16, but eslint-plugin-unicorn says it supports v14 and up.

The original error message:

Error: Failed to load plugin 'unicorn' declared in '.eslintrc.json': Cannot find module 'node:path'
Require stack:
- eslint-plugin-unicorn@43.0.2_eslint@8.20.0/node_modules/eslint-plugin-unicorn/rules/utils/rule.js
- eslint-plugin-unicorn@43.0.2_eslint@8.20.0/node_modules/eslint-plugin-unicorn/index.js
- @eslint+eslintrc@1.3.0/node_modules/@eslint/eslintrc/dist/eslintrc.cjs

The issue occurs after upgrading from 42.0.0 to 43.0.2.

It's a bit confusing that the tests are passing despite that they're running with v14, too.

@electerious
Copy link
Author

My fault. node: is supported since v14.13.1, but my version was slightly below.

@axelboc
Copy link

axelboc commented Aug 8, 2022

I've just hit this. Seems that Node 14.13.1+ only supports node:* imports from ESM files -- not from CJS files. I found the info here: gregnb/filemanager-webpack-plugin#101 (comment).

I recommend re-opening this issue and either increasing the minimum Node version to v16, reverting to unprefixed paths, or making sure the node: prefixes are removed in the CJS output.

@axelboc
Copy link

axelboc commented Aug 8, 2022

Okay, got it: they've added support for node:* imports from CJS in Node 14.18.0: https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V14.md#2021-09-28-version-14180-fermium-lts-targos. I was confused, because I was seeing the error with Node 14.15, so after 14.13.1.

Bumping the minimum Node version to v14.18.0 should do the trick.

@bmish
Copy link
Sponsor Contributor

bmish commented Aug 8, 2022

We could mention the Node version support in the rule doc to reduce confusion here: #1874

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 a pull request may close this issue.

3 participants