tsx: Latest version of `tsx` causes `TypeError` `not a function`
Acknowledgements
- I read the documentation and searched existing issues to avoid duplicates
- I understand this is a bug tracker and anything other than a proven bug will be closed
- I understand this is a free project and relies on community contributions
- I read and understood the Contribution guide
Minimal reproduction URL
https://github.com/SynthLuvr/tsx-bug
Problem & expected behavior (under 200 words)
To reproduce:
➜ git clone git@github.com:SynthLuvr/tsx-bug.git
➜ pnpm install
➜ pnpm tsx bug.ts
tsx-bug/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_memoizeCapped.js:15
var result = memoize(func, function(key) {
^
TypeError: memoize is not a function
The culprit appears to be calling generateSeedPhrase() from @lucid-evolution/lucid before calling mnemonicToEntropy from bip39. For example, this works:
➜ pnpm tsx works.ts
e06ed2f736818e37420392a84251b4e996caa7b1348a02a06250bea9fff30a9f
Downgrading tsx to 4.19.4 works:
➜ pnpm install tsx@4.19.4
➜ pnpm tsx bug.ts
e70f70afef0ac3842ee84350a23216cd1e13474ca2ccfba3ad4162a6034f705a
Bugs are expected to be fixed by those affected by it
- I’m interested in working on this issue
Compensating engineering work will speed up resolution and support the proj
- I’m willing to offer $10 for financial support
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 23
- Comments: 16 (3 by maintainers)
Commits related to this issue
- fix: lock tsx version due https://github.com/privatenumber/tsx/issues/727 — committed to web-infra-dev/midscene-example by quanru a year ago
- fix: lock tsx version due https://github.com/privatenumber/tsx/issues/727 (#53) — committed to web-infra-dev/midscene-example by quanru a year ago
Sorry for the disruption everyone! This release took a lot of work and was thoroughly tested before release but looks like it wasn’t enough.
Thanks to everyone that provided a reproduction—now we’ll have them as tests to ensure they pass before the next release.
I reverted the problematic changes for now: https://github.com/privatenumber/tsx/releases/tag/v4.20.3
I’ll keep investigating the root cause and aim to release a version that works across all Node versions soon.
Seems that since v4.20.2 I also get errors caused by wrong imports. Related to module resolution.
The commit that caused the issue seems to be
c1882680bce9df3052bef23dbed1b95728e802bband the file with the issue issrc/esm/hook/load.tsWithout changing any code and everything working with version
4.20.1updating to4.20.2I get this error using the import_client_dynamodb.GetItemCommand is not a constructor when using@aws-sdk/client-dynamodbFeels related to this error.
If you are in the same case as me with shebang on a script to create a binary with npx or are using npx, I tried to add the previous version to the command to lock de version and it seems to work fine:
#!/usr/bin/env -S npx --yes tsx@4.20.1it is not a final solution but it might keep you safe from unexpected problems from unstable versions.In my case the TypeError is with
@kwsites/file-existsmodule (dependency of simple-git). However if I remove the module it keeps failing with other modules. It seems to be something wrong with export resolutions and commonjs as default is the keyword for exports in esm.