I followed a guide to configure path alias at , but unfortunately, it's not working as expected.
Recently I started a new Bun project with the intention of migrating a Node
app to Bun
. Here are the steps I took:
Create a directory and initialize the Bun project by running
mkdir bun-test && cd bun-test && bun init
After initializing the project, I added the following code to
tsconfig.ts
{
"compilerOptions": {
...
"baseUrl": "./src",
"paths": {
"config": ["./src/config/appConfig.ts"]
}
}
}
- Create a file named
src/config/appConfig.ts
export default {
message: "My first bun application"
};
- Make changes in
src/index.ts
.
import appConfig from "config";
console.log(appConfig.message);
- Although VSCode intellisense is resolving the paths correctly, when I run the app using
bun run ./src
, it throws an error
error: Cannot find package "config" from "/bun-test/src/index.ts"
Bun v1.1.29 (Linux x64)
I'm facing this issue, what could be causing it? Am I missing any steps? Your help would be appreciated!