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(core): pass the full resolved path of ts-node/esm when reloading the CLI #21607

Merged
merged 1 commit into from Feb 5, 2024

Conversation

jaysoo
Copy link
Member

@jaysoo jaysoo commented Feb 5, 2024

When we reload the process for Node 18 in order to support ESM .ts files, we need to pass the fully resolved path. Otherwise, the --loader ts-node/esm option may error out when it is not hoisted.

Current Behavior

If you try to run Nx CLI in a repo that does not have ts-node hoisted to the top-level node_modules, it will error out like this:

Did you mean to import ts-node@10.9.1_@swc+core@1.3.107_@types+node@18.19.14_typescript@5.3.3/node_modules/ts-node/esm.mjs?
    at new NodeError (node:internal/errors:405:5)
    at packageResolve (node:internal/modules/esm/resolve:890:9)
    at moduleResolve (node:internal/modules/esm/resolve:939:20)
    at defaultResolve (node:internal/modules/esm/resolve:1132:11)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:835:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ESMLoader.import (node:internal/modules/esm/loader:524:22)
    at loadModulesInIsolation (node:internal/process/esm_loader:92:34)
    at initializeLoader (node:internal/process/esm_loader:61:25) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Expected Behavior

Nx CLI should reload correctly.

Related Issue(s)

Fixes #

@jaysoo jaysoo requested a review from a team as a code owner February 5, 2024 15:14
@jaysoo jaysoo requested a review from Cammisuli February 5, 2024 15:14
Copy link

vercel bot commented Feb 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Feb 5, 2024 3:15pm

@jaysoo jaysoo merged commit b97958c into nrwl:master Feb 5, 2024
6 checks passed
@jaysoo jaysoo deleted the fix_esm_reload branch February 5, 2024 17:11
FrozenPandaz pushed a commit that referenced this pull request Feb 5, 2024
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants