oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.16k stars 2.77k forks source link

Cannot find module "typeorm/util/StringUtils" from "/usr/src/app/src/lib/typeorm/snake-naming.ts" #6285

Open axeldelafosse opened 1 year ago

axeldelafosse commented 1 year ago

What version of Bun is running?

1.0.4+745b6b94ee56cad24d475799690cc9a89957d15b

What platform is your computer?

Darwin 23.0.0 arm64 arm

What steps can reproduce the bug?

Run bun dist/main.js in a NestJS app using a similar typeorm import as https://github.com/tonivj5/typeorm-naming-strategies/blob/master/src/snake-naming.strategy.ts

What is the expected behavior?

$ DB_HOST=localhost REDIS_HOST=localhost PORT=4001 bun dist/main.js

[Nest] 82727  - 10/04/2023, 10:56:20 AM     LOG [NestFactory] Starting Nest application...
[Nest] 82727  - 10/04/2023, 10:56:20 AM     LOG [InstanceLoader] TypeOrmModule dependencies initialized +47ms

What do you see instead?

2023-10-04 11:01:14 $ DB_HOST=localhost REDIS_HOST=localhost PORT=4001 bun dist/main.js
2023-10-04 11:01:15 error: Cannot find module "typeorm/util/StringUtils" from "/usr/src/app/src/lib/typeorm/snake-naming.ts"
2023-10-04 11:01:15 error: script "start:prod" exited with code 1 (SIGHUP)

Additional information

No response

tuan-zigvy commented 11 months ago

I have bug like you

image

Zikoat commented 9 months ago

Workaround:

import { camelCase } from 'typeorm/util/StringUtils.js';

Add .js to the end

Reproduction:

Expected behavior when the ts file is compiled with tsc and run with node:

bun i typescript typeorm
echo "import { camelCase } from 'typeorm/util/StringUtils';console.log(camelCase('correct_output'))" > temp.ts
bun run tsc temp.ts
node temp.js

> correctOutput

Actual behavior when running file directly with bun:

bun i typeorm
echo "import { camelCase } from 'typeorm/util/StringUtils';console.log(camelCase('correct_output'))" > temp.ts
bun run temp.ts

> error: Cannot find module "typeorm/util/StringUtils" from "/home/zikoat/dev/repro-bug/temp.ts"

@Electroid Repro given, can you tag this correctly?

github-actions[bot] commented 3 months ago

This issue is stale and may be closed due to inactivity. If you're still running into this, please leave a comment.