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

Bug: Cannot find module './cli.cjs' #875

Open
BenRacicot opened this issue Feb 6, 2024 · 9 comments
Open

Bug: Cannot find module './cli.cjs' #875

BenRacicot opened this issue Feb 6, 2024 · 9 comments

Comments

@BenRacicot
Copy link

BenRacicot commented Feb 6, 2024

Hello,
Hi @tada5hi I'm getting the error below (767) after updating to the latest version. (I've read the docs)

We confirmed this error on a Ubuntu environment and my own MacOS, where Windows 10 ran error-free.

...
query: INSERT INTO `development`.`migrations`(`timestamp`, `name`) VALUES (?, ?) -- PARAMETERS: [1707340742888,"Init1707340742888"]
Migration Init1707340742888 has been  executed successfully.
query: COMMIT
node:internal/modules/cjs/loader:1147
  throw err;
  ^

Error: Cannot find module './cli.cjs'
Require stack:
- /Users/home/dev/recruitler/node-modules/typeorm-extension/bin/imaginaryUncacheableRequireResolveScript
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Function.resolve (node:internal/modules/helpers:187:19)
    at requireResolveNonCached (/Users/home/.nvm/versions/node/v20.10.0/lib/node_modules/ts-node/dist/bin.js:549:16)
    at getProjectSearchDir (/Users/home/.nvm/versions/node/v20.10.0/lib/node_modules/ts-node/dist/bin.js:519:40)
    at phase3 (/Users/home/.nvm/versions/node/v20.10.0/lib/node_modules/ts-node/dist/bin.js:267:27)
    at bootstrap (/Users/home/.nvm/versions/node/v20.10.0/lib/node_modules/ts-node/dist/bin.js:47:30)
    at main (/Users/home/.nvm/versions/node/v20.10.0/lib/node_modules/ts-node/dist/bin.js:33:12)
    at Object.<anonymous> (/Users/home/.nvm/versions/node/v20.10.0/lib/node_modules/ts-node/dist/bin.js:579:5)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/home/dev/recruitler/node-modules/typeorm-extension/bin/imaginaryUncacheableRequireResolveScript'
  ]
}

Node.js v20.10.0

I do see that node-modules/typeorm-extension/bin/imaginaryUncacheableRequireResolveScript does not exist.
Two of us are at a loss, could you guide me on this update? :)

Versions

  • Node: 20.10.00
  • OS: Replicated on Ubuntu 20.04, MacOS 14.3 -
  • (Windows 10 runs seed without the error)

Reproduction

Update from typeorm-extension: ^2.8.1 to 3.4.0 and run seed script to see error above.
(confirmed on multiple environments)

@BenRacicot BenRacicot changed the title Bug: Bug: Cannot find module './cli.cjs' Feb 6, 2024
@tada5hi
Copy link
Owner

tada5hi commented Feb 7, 2024

@BenRacicot the error is really strange. Can you do me a favor and check:

  1. if the error persists with node version 18.x?
  2. if the error persists with node version 20.x and typeorm-extension version v3.4.1-beta.1?

@tada5hi
Copy link
Owner

tada5hi commented Feb 7, 2024

PS: thanks for sponsoring ❤️

@BenRacicot
Copy link
Author

BenRacicot commented Feb 7, 2024

Hi!
About 3.4.1-beta.1
I can confirm the same error on MacOS / Node 20.10.0 and 18.12 (used nvm to swap versions)

About 3.4.0
We confirmed the error on Ubuntu and MacOS with Node 20.10.0

We spent many hours today trying to run our old seed script but only have it running on a Windows 10 / Node 20.10.0

I should add that the script does create and run the mig files

...
query: INSERT INTO `development`.`migrations`(`timestamp`, `name`) VALUES (?, ?) -- PARAMETERS: [1707340742888,"Init1707340742888"]
Migration Init1707340742888 has been  executed successfully.
query: COMMIT
node:internal/modules/cjs/loader:1147
  throw err;
  ^

@tada5hi
Copy link
Owner

tada5hi commented Feb 8, 2024

damm. i was hoping that it was due to the exports for the bin directory.
Are you using the latest version of ts-node ?

@BenRacicot
Copy link
Author

Hi, yeah so we've been battling this pretty hard. We created a MacOS VM and can replicate it on that, My personal MBP and my M1 MBP. All have latest version of everything. ts-node etc.

I do believe we've found a common bug with typeorm-extension and MacOS. I'm sorry myself and my partner have no idea what is causing it.

@tada5hi
Copy link
Owner

tada5hi commented Feb 8, 2024

The problem also occurred in other projects.

TypeStrong/ts-node#2099

Maybe the last comment does help you too.

@BenRacicot
Copy link
Author

Yes that is interesting, same exact error. We rolled back to "typeorm-extension": "^2.8.1" the version we upgraded from and may stay there for a while.

If we can help, please know we're open to give of our time.

@emerilek
Copy link

emerilek commented May 2, 2024

I've got a M processor on MBP too and we got the problem since we update typeorm-extension from '2.8.1' to '3.5.x'...

@BenRacicot
Copy link
Author

BenRacicot commented Nov 15, 2024

Wow, just ran into this again on a fresh project.

"typeorm": "^0.3.20",
"typeorm-extension": "3.6.3",

Updating Global packages and Node simply solved this

npm install -g typescript
npm install -g ts-node

# Depending on configuration, you may also need these
npm install -D tslib @types/node

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants