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

Usage of node:path is incompatible with declared engines #55

Closed
kachkaev opened this issue Sep 20, 2021 · 3 comments
Closed

Usage of node:path is incompatible with declared engines #55

kachkaev opened this issue Sep 20, 2021 · 3 comments

Comments

@kachkaev
Copy link

👋 @sindresorhus!

I was fiddling with prettier-vscode and noticed an issue with find-up’s import from node:path. When running yarn test, the extension was crashing by saying that it could not resolve node:path.

According to v6.0.0 CHANGELOG and package.json → engines, find-up is expected to work on any Node version that supports ESM. However, looks like node:path import has a stricter constraint, more specifically Node 14.18 and Node 16+.

@sindresorhus
Copy link
Owner

It is supported on Node.js 12 since 12.20:

find-up/package.json

Lines 15 to 17 in ace3d10

"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},

@sindresorhus
Copy link
Owner

@kachkaev
Copy link
Author

kachkaev commented Oct 3, 2021

I must have been confused by the difference between require('node:something') and import('node:something') which may work not the same way. Typing require('node:something') in Node v12.22.6 and Node v14.17.0 REPL produces Uncaught Error: Cannot find module 'node:something', which is not the case for import('node:something') — this statements works. The behaviour is fixed in Node v14.18.0, thanks to nodejs/node#37246.

Prettier for VSCode is built by webpack and so import path from 'node:path' in find-up gets replaced by require and breaks. This is not a problem of find-up though – seems that downstream webpack setups need to account for different support for require('node:something') and import('node:something') when bundling.

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

No branches or pull requests

2 participants