I config path alias following this guide: https://bun.sh/guides/runtime/tsconfig-paths. But it’s not work
I create a Bun project (I’m planning to migrate a Node
app to Bun
) by these steps:
-
mkdir bun-test && cd bun-test && bun init
-
After init project, I add to
tsconfig.ts
{
"compilerOptions": {
...
"baseUrl": "./src",
"paths": {
"config": ["./config/appConfig.ts"]
}
}
}
- Create
src/config/appConfig.ts
export default {
message: "My first bun application",
};
- Modify
src/index.ts
.
import appConfig from "config";
console.log(appConfig.message);
- VSCode intellisense resolve the path well, but when run app
bun run ./src
it throw error
error: Cannot find package "config" from "/bun-test/src/index.ts"
Bun v1.1.29 (Linux x64)
What problem here? Am i missing some step?