oven-sh / bun

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

Bun link works but installs says package is not linked #4719

Open erikkrieg opened 1 year ago

erikkrieg commented 1 year ago

What version of Bun is running?

1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983

What platform is your computer?

Darwin 22.6.0 arm64 arm

What steps can reproduce the bug?

What is the expected behavior?

Ideally I shouldn't have to manually run the link command at all since the path to the linked directory is in the root package.json and then in either case the install should not fail claiming the link does not exist when it actually does.

What do you see instead?

I see the symlink in node_modules, but the install command always fails.

Additional information

I installed the bun binary using Nix package manager. I don't think this is likely to matter, since it is just copying the built binary from Bun's GitHub releases, but just to be thorough I'm mentioning it.

Another thing, the custom scope being used for the linked module is the same as a scope that points to a private registry. So I'm wondering if there could be an unexpected dynamic involving this.

rattrayalex commented 1 year ago

Also hitting this.

We have this in our root package.json under "devDependencies":

    "eslint-plugin-stainless": "link:./lib/eslint-plugin-stainless",

and the contents of ./lib/eslint-plugin-stainless/package.json is as follows:

{
  "name": "eslint-plugin-stainless",
  "version": "1.0.0",
  "main": "./index.js"
}

here's what I run and see:

[11:57:03] [~/code/stainless] [main]
➜  cd lib/eslint-plugin-stainless 

[11:57:06] [~/code/stainless/lib/eslint-plugin-stainless] [main]
➜  bun link
bun link v1.0.0 (822a00c4)
Success! Registered "eslint-plugin-stainless"

To use eslint-plugin-stainless in a project, run:
  bun link eslint-plugin-stainless

Or add it in dependencies in your package.json file:
  "eslint-plugin-stainless": "link:eslint-plugin-stainless"

[11:57:11] [~/code/stainless/lib/eslint-plugin-stainless] [main]
➜  cd -
~/code/stainless

[11:57:25] [~/code/stainless] [main]
➜  bun link eslint-plugin-stainless
bun link v1.0.0 (822a00c4)

 installed eslint-plugin-stainless@link:eslint-plugin-stainless

patch-package 8.0.0
Applying patches...
yaml-diff-patch@2.0.0 ✔

 6 packages installed [3.31s]

[11:57:36] [~/code/stainless] [main]
➜  bun install
bun install v1.0.0 (822a00c4)

error: package "eslint-plugin-stainless" is not linked

To install a linked package:
   bun link my-pkg-name-from-package-json

Tip: the package name is from package.json, which can differ from the folder name.
preshonyee commented 1 year ago

I have the same issue, not sure how to fix this

CleanShot 2023-09-12 at 08 21 33@2x

CleanShot 2023-09-12 at 08 21 10

devonpmack commented 1 year ago

Same issue

package.json

  "dependencies": {
    "@sketch/shared-types": "link:./src/shared_types",
image
Nasseratic commented 1 year ago

same here :)

    "eslint-plugin-lenus-mobile-custom-rules": "link:./packages/mobile-eslint-rules",
jlamoreaux commented 1 year ago

Seeing the same issue here. I've tried using bun link <package-name> in the app directory and adding <package-name>: link:<package-name> to package.json. Neither seems to work.

Parsifal-M commented 1 year ago

Hey, also facing this issue, the bun link says it has linked the package but then after a bun install it says that it's not linked. 😭

alchemistake commented 10 months ago

I experience same issue but weirdly it works on one my repos but not the second one. I linked a lib called damageCalc in repo A later that week i linked it in repo B as well. It works on Repo A but not Repo B

Edit: Library is TS, Repo A is JS and Repo B is TS. So when i convert the files into JS on Repo B they "magically" work. Then I thought it might be my error and tested on my other computer. It links correct on my linux computer and typing definitions resolve as well. The machine with error is an M1 Mac.

bitofbreeze commented 6 months ago

The fix for me was putting the new "file:" prefix instead of "link:" in package.json for the linked dependencies. Found here

sohaieb commented 5 months ago

I confirm the same issue. I also tried mentioned suggestions above but none of them worked for me.

JacobReynolds commented 4 months ago

I've been running into the same issue, using "@org/dep": "workspace:*" fixes it for me. I'm not clear if that's the same as linking though. Taken from here.

musilimu commented 4 weeks ago

For me I had

muslim@uwi:~/Documents/projects/wildlife-fe$ bun install
bun install v1.1.26 (0a37423b)
error: Package "wildlife-fe" is not linked

To install a linked package:
   bun link my-pkg-name-from-package-json

Tip: the package name is from package.json, which can differ from the folder name.

error: wildlife-fe@link: failed to resolve

What I did was to remove the package from package.json and bun install and it worked