bun
bun copied to clipboard
Install command puts all dependencies into monorepo root if workspace name is same as one of its dependencies
What version of Bun is running?
1.1.3
What platform is your computer?
Microsoft Windows NT 10.0.19045.0 x64
What steps can reproduce the bug?
Works for just install command and for running create-something installer packages. Using create-next-app as example here
bun init, accept defaults- In package.json add
"workspaces": ["apps/*"]and create ./apps folder in project - Cd into ./apps and
bunx --bun create-next-app@latest next, accept defaults, wait for process to finish
What is the expected behavior?
All dependencies for next (folder in our project) are under ./apps/next/node_modules
What do you see instead?
The only dependency in this folder is next
All other dependencies are in project root under ./node_modules
.
├── apps/
│ └── next/
│ ├── node_modules/
│ │ ├── .bin (is it even relevant here?)/
│ │ │ ├── next.bunx
│ │ │ └── next.exe
│ │ ├── next (the only dependency here)
│ │ └── (all other dependencies should be here)
│ └── package.json (has "next" dependency)
├── node_modules/
│ ├── react (should be in ./apps/next/node_modules)
│ └── react-dom (and this too)
└── package.json (no "react" or "react-dom" dependencies here)
Additional information
No response
There seem to be more to this problem. It puts all dependencies from all workspaces into root. And the only exception happens to be when workspace name matches dependency name.
Alternatively, if it is intended behavior, the bug is when scripts and libraries are unable to find required dependencies in root.
I understand now what exactly happens here. Original description is only half correct. Main issue here is that bun confuses folder in our project with dependency used in there - if their names match. It thinks project folder is dependency installed locally, so it simply links dependency to this project folder.
On example from first post: next (folder) has dependency next (package). So when it encounters next (package) in package.json, it creates link to next (folder). And as expected, everything breaks because contents of next (folder) is not what should be inside next (package)