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

Bun install does not install dependencies between packages in the same monorepo #4650

Closed
nbbaier opened this issue Sep 9, 2023 · 10 comments
Closed
Labels
bug Something isn't working npm Something that relates to the npm-compatible client

Comments

@nbbaier
Copy link

nbbaier commented Sep 9, 2023

What version of Bun is running?

1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983

What platform is your computer?

Darwin 22.5.0 arm64 armw

What steps can reproduce the bug?

Following the guide for setting up a monorepo here:

Project structure:

.
├── package.json
├── node_modules
└── packages
    ├── stuff-a
    │   └── package.json
    └── stuff-b
        └── package.json

Root package.json

{
  "name": "my-monorepo",
  "private": true,
  "workspaces": ["packages/*"]
}

Stuff-b package.json

{
  "name": "stuff-b",
  "dependencies": {
   "stuff-a": "*"
  }
}

What is the expected behavior?

Running bun install from the project root to install dependencies for all workspaces.

What do you see instead?

I get the following error:

bun install v1.0.0 (822a00c4)
  🔍 stuff-a [1/1] 
error: package "stuff-a" not found registry.npmjs.org/stuff-a 404
error: stuff-a@* failed to resolve

Additional information

No response

@nbbaier nbbaier added the bug Something isn't working label Sep 9, 2023
@divmgl
Copy link

divmgl commented Sep 9, 2023

You need to provide a version for stuff-a. * won't work.

@nbbaier
Copy link
Author

nbbaier commented Sep 9, 2023

Thanks, but even with an explicit version, it still fails.

Revised packages/stuff-b/package.json

{
  "name": "stuff-b",
  "dependencies": {
    "stuff-a": "1.0.0"
  }
}

packages/stuff-a/package.json

{
    "name": "stuff-a",
    "version": "1.0.0"
}

Error:

bun install v1.0.0 (822a00c4)
  🔍 stuff-a [1/1] 
error: package "stuff-a" not found registry.npmjs.org/stuff-a 404
error: stuff-a@1.0.0 failed to resolve

@nil1511
Copy link

nil1511 commented Sep 9, 2023

Faced a similar issue. explicitly specifying as workspace dependency fixes it

  "name": "stuff-b",
  "dependencies": {
   "stuff-a": "workspace:*"
  }
}

@ramiel
Copy link

ramiel commented Sep 9, 2023

This didn't fix the problem for me

@noClaps
Copy link

noClaps commented Sep 9, 2023

I've found that you don't need to declare packages in a monorepo as dependencies of each other. They're automatically added to node_modules, so you can use them directly.

"dependencies": {
// other dependencies
-  "stuff-a": "*"
}

@benvan
Copy link

benvan commented Sep 9, 2023

@ramiel I had a similar issue. Re. "This didn't fix the problem for me", try deleting your bun lock file and re-running bun install
Context #4676

@nbbaier
Copy link
Author

nbbaier commented Sep 9, 2023

@benvan that worked for a first bun install but then if I run bun add zod (or something else) in packages/stuff-b, I get the same error, i.e. the stuff-a dependency can't be resolved and the add fails

@2coo
Copy link

2coo commented Sep 11, 2023

I am facing the same behavior as his

@ramiel
Copy link

ramiel commented Sep 11, 2023

Removing the lock file worked for me

@Electroid Electroid added the npm Something that relates to the npm-compatible client label Oct 27, 2023
@dylan-conway
Copy link
Collaborator

This is fixed in bun v1.1.8 and newer versions.

@benvan that worked for a first bun install but then if I run bun add zod (or something else) in packages/stuff-b, I get the same error, i.e. the stuff-a dependency can't be resolved and the add fails

We also landed #11177 in v1.1.9 which fixes adding dependencies within a workspace.

Please reopen or create a new issue if you continue to find install bugs in the latest release of bun.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working npm Something that relates to the npm-compatible client
Projects
None yet
Development

No branches or pull requests

9 participants