-
Notifications
You must be signed in to change notification settings - Fork 994
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: import yargs/yargs in esm projects #2151
Conversation
This is already happening with Node.js >= 12 as far as I can see. The The failing test is running a ESM project with this package.json: {
"name": "bandersnatch-smoke-test-esm",
"type": "module",
"scripts": {
"test": "node index.mjs"
},
"dependencies": {
"bandersnatch": "^1.9.2"
}
}
import createYargs from 'yargs/yargs'; |
@bcoe Is there anything I can do to help this get merged? I could add a simple smoke test (like in the |
@hongaar thank you for the patch, hopefully it does the trick for you. |
Due to the `yargs.mjs` file not being published, the fix merged with yargs#2151 is not effective yet. This change should fix that. ``` Cannot find module './node_modules/yargs/yargs.mjs' imported from ./cli.js ```
When using
import yargs from "yargs/yargs"
in an ESM project ("type": "module"
in package.json), Node.js will throw this error:To solve this, add a new
yargs.mjs
file and update the./yargs
export in the package.json.Confirmed that this works for a simple ESM project where
yargs
is a transitive dependency: hongaar/bandersnatch#392 (intests/smoke/esm
)Related to #2014