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

tsx doesn't work on Node 18.19 #421

Closed
4 of 5 tasks
brc-dd opened this issue Nov 30, 2023 · 1 comment · Fixed by #422
Closed
4 of 5 tasks

tsx doesn't work on Node 18.19 #421

brc-dd opened this issue Nov 30, 2023 · 1 comment · Fixed by #422
Labels

Comments

@brc-dd
Copy link
Sponsor Contributor

brc-dd commented Nov 30, 2023

Precheck

  • I searched existing issues before opening this one to avoid duplicates
  • I'm able to reproduce this issue and prove it with a minimal reproduction
  • I understand this is not a place to ask for free debugging support

Problem

Unable to run tsx on Node 18:

❯ pnpm tsx ./foo.ts         

node:internal/process/esm_loader:40
      internalBinding('errors').triggerUncaughtException(
                                ^
Error: tsx must be loaded with --import instead of --loader
The --loader flag was deprecated in Node v20.6.0
    at Q (file:///Users/divyansh/foo/node_modules/.pnpm/tsx@4.6.0/node_modules/tsx/dist/esm/index.mjs:1:1793)
    at Hooks.addCustomLoader (node:internal/modules/esm/hooks:202:24)
    at Hooks.register (node:internal/modules/esm/hooks:168:16)
    at async initializeHooks (node:internal/modules/esm/utils:167:5)
    at async customizedModuleWorker (node:internal/modules/esm/worker:104:24)

Node.js v18.19.0

Working fine till Node v18.18 (https://nodejs.org/en/blog/release/v18.19.0#esm-and-customization-hook-changes)

Minimal reproduction

// foo.ts:

console.log('hello')

// on terminal:

nvm use 18
pnpm add -D tsx
pnpm tsx ./foo.ts

Expected behavior

Not fail on LTS versions.

Version

v4.6.0

Node.js version

v18.19.0

Package manager

pnpm

Operating system

macOS

Contributions

  • I plan to open a pull request for this issue
  • I plan to make a financial contribution to this project
@brc-dd brc-dd added bug Something isn't working pending triage labels Nov 30, 2023
@brc-dd brc-dd changed the title tsx doesn't work on Node 18 tsx doesn't work on Node 18.19 Nov 30, 2023
@privatenumber
Copy link
Owner

🎉 This issue has been resolved in v4.6.1

If you appreciate this project, please consider supporting this project by sponsoring ❤️ 🙏

smallsaucepan added a commit to smallsaucepan/turf that referenced this issue Dec 11, 2023
smallsaucepan added a commit to Turfjs/turf that referenced this issue Dec 18, 2023
* Moving to pnpm as package manager. Also taking the opportunity to tidy up our cjs / esm situation using tsup (instead of tsc and rollup). Can't get monorepolint to work with new setup so disabling for the time being.

* Changing all Turf imports to use named imports. Adding a few missing named exports. Updating github workflow actions to pnpm instead of yarn.

* Updating typescript module and moduleResolution mechanisms to "node16". Not tracking nodenext just yet. Changing tsup command to generate d.ts files that arethetypeswrong approves of.

* Tweaking github workflows to explicitely install pnpm.

* Looks like node needs the chosen cache binary installed first. Trying without cache as a first step.

* Seem to be hitting the tsx bug described here: privatenumber/tsx#421 Upgrading to latest tsx to remedy.

* Forgot to update lock file after updating tsx dep in package.json files.

* Sorting modules exported from @turf/turf alphabetically. Preparatory commit to add unexported modules.

* Converting index.mjs to typescript, and simplifying re-exported imports, and ordering alphabetically. Added in a couple of packages - convex, booleanValid and nearestNeighbourAnalysis. Rollup now only used in packages/turf so merging project root base config into there. Also now only using rollup in packages/turf to do final conversion to web module. JS and d.ts files generated the same as other modules, using tsup.

* Including tslib in @turf/turf build now that it's a TS module.

* Lot of per-package tsconfig items now on the tsup command line, so stripping back tsconfig.json to the bare minimum. Adding tsconfig.json to packages that while still only JS, are now processed by tsup.

* Same as last commit - simplifying tsconfig.json - except these are the subset of packages that had multiple entry points e.g. 3rd party code hosted locally in lib/

* Incorporating some suggestions from @favna on being more explicit with d.ts entries. #2307 (comment)  Specifying overall module type as commonjs explicitly.

* Reapplying cjsInterop / splitting workaround for CJS exports that we had on build target command line earlier in this PR in to tsup config file. Also disabling treeshaking as this was generating a warning for CJS files and causing the workaround above to not work.

* Upgrading rollup and related plugins. Updating to recommended modern browserslist config in babel.config.json e.g. previous chrome 67 and edge 17 are 5 years old, ie11 is just ... ugh

* Fluffed the browserslist config - need to cover es5 as well.

* Update .github/workflows/turf.yml to use actions/checkout v4.

Co-authored-by: Jeroen Claassens <jeroen.claassens@live.nl>

---------

Co-authored-by: Jeroen Claassens <jeroen.claassens@live.nl>
turadg added a commit to Agoric/agoric-sdk that referenced this issue Jan 10, 2024
turadg added a commit to Agoric/agoric-sdk that referenced this issue Jan 11, 2024
turadg added a commit to Agoric/agoric-sdk that referenced this issue Jan 11, 2024
sapegin added a commit to tacohuaco/tacohuaco that referenced this issue Jan 22, 2024
Try to fix build error:

Error: tsx must be loaded with --import instead of --loader
The --loader flag was deprecated in Node v20.6.0

privatenumber/tsx#421
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants