-
-
Notifications
You must be signed in to change notification settings - Fork 536
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
Cannot find dependent packages while using ts-node-esm
with yarn berry
under pnp mode
.
#1941
Comments
Update the {
"compilerOptions": {
...,
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true
}
} |
I have the same issue |
Try |
I use |
Same issue here, even with Tried: $ yarn exec ts-node-esm "$script"
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '/xxx/.yarn/__virtual__/ts-node-virtual-xxx/0/cache/xxx/ts-node-npm-10.9.1-xxx.zip/node_modules/ts-node/child-loader.mjs' imported from $script
$ yarn exec ts-node --esm "$script"
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '/xxx/.yarn/__virtual__/ts-node-virtual-xxx/0/cache/xxx/ts-node-npm-10.9.1-xxx.zip/node_modules/ts-node/child-loader.mjs' imported from $script
$ yarn node --loader ts-node/esm "$script"
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'ts-node' imported from $script
$ yarn node --loader "$(yarn node -p 'require.resolve("ts-node/esm")')" "$script"
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '/xxx/.yarn/__virtual__/ts-node-virtual-xxx/0/cache/xxx/ts-node-npm-10.9.1-xxx.zip/node_modules/ts-node/esm.mjs' imported from $script Figured maybe it's just a compatibilit issue with Yarn's $ yarn exec ts-node-esm "$script"
/xxx/.yarn/unplugged/ts-node-virtual-xxx/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:757
throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base));
^
CustomError: Cannot find package '$dependency' imported from $script
$ yarn exec ts-node --esm "$script"
/xxx/.yarn/unplugged/ts-node-virtual-xxx/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:757
throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base));
^
CustomError: Cannot find package '$dependency' imported from $script
$ yarn node --loader ts-node/esm "$script"
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'ts-node' imported from $script
$ yarn node --loader "$(yarn node -p 'require.resolve("ts-node/esm")')" "$script"
/xxx/.yarn/unplugged/ts-node-virtual-xxx/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:757
throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base));
^
CustomError: Cannot find package '$dependency' imported from $script |
ts-node really can not resolve Node third-part dependencies |
Working example for yarn -v
3.5.0
yarn add -DE ts-node
# any loaders must be unplugged or you'll get ERR_MODULE_NOT_FOUND
yarn unplug ts-node
# chain loaders, --loader ./.pnp.loader.mjs must be last
yarn node --loader file://$(yarn node -p \"require.resolve('ts-node/esm')\") --loader ./.pnp.loader.mjs scripts/bootstrap.ts |
Thanks! @psychobolt I want to add comments solving a problem. "ts-node": {
"transpileOnly": true,
"esm": true,
} |
use |
@psychobolt (node:15764) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
node:internal/modules/run_main:122
triggerUncaughtException(
^
[Object: null prototype] {
[Symbol(nodejs.util.inspect.custom)]: [Function: [nodejs.util.inspect.custom]]
}
Node.js v22.10.0 Referring to the known issue:
And the question still remains: |
@LvChengbin |
@MyNameIsNeXTSTEP I apologize for not resolving this issue. I attempted to migrate my projects to use esmodule, but ran into several roadblocks that proved challenging to overcome. I'll try again in the future. |
Search Terms
Expected Behavior
Actual Behavior
Cannot find dependent packages while using
ts-node-esm
withyarn berry
underpnp mode
.I'm not sure if it should be an issue of
ts-node
project, but it's working well while usingyarn node
command andyarn ts-node
command.I know the issue of chaining loaders of nodejs, so I upgraded my nodejs to the latest version (19.4.0) which seems has already supported chaining loaders.
Steps to reproduce the problem
Sample code:
Minimal reproduction
Specifications
The text was updated successfully, but these errors were encountered: