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

pnpm link should not change package.json #4341

Closed
farfromrefug opened this issue Feb 15, 2022 · 10 comments · Fixed by #6513
Closed

pnpm link should not change package.json #4341

farfromrefug opened this issue Feb 15, 2022 · 10 comments · Fixed by #6513
Assignees

Comments

@farfromrefug
Copy link

Right now whenever you use pnpm link to link a local or global package (like for dev testing packages) the version of the package is changed in the package.json from like 3.2.1 to ^3.2.1.
I see that as quite a big issue because it breaks the forkflow of forced specified version of packages.

Is there any reason for this? Could we stop that behavior?

@zkochan
Copy link
Member

zkochan commented Feb 16, 2022

No, I don't think there is a reason for it. Looks like a bug.

@BlackHole1
Copy link
Member

BlackHole1 commented Feb 22, 2022

I have no local recurrence. my pnpm version: pnpm@7.0.0-alpha.3

Can you provide a demo and steps to recurrence it?

cc: @farfromrefug

@farfromrefug
Copy link
Author

have 2 different folders
one is the module the other uses the module (without ^)
inside the module do pnpm link --global
inside the other one do pnpm link --global my-module
then the dependency in the package.json gets changed with a ^
i havent tried with 7.0

@BlackHole1
Copy link
Member

my-module

package.json:

{
  "version": "1.0.0"
}

my-project

package.json:

{
  "dependencies": {
  }
}

shell

$ cd my-module
$ pnpm link --global

$ cd my-project
$ pnpm link --global my-module
$ cat my-project/package.json
{
  "dependencies": {
    "my-module": "^1.0.0"
  }
}

Are you wanting to get the following?

$ cat my-project/package.json
{
  "dependencies": {
    "my-module": "1.0.0"
  }
}

@farfromrefug
Copy link
Author

@BlackHole1 well if the module is not yet in the dependencies i dont care. But if i have

"dependencies": {
    "my-module": "1.0.0"
  }

I expect it NOT to change to

"dependencies": {
    "my-module": "^1.0.0"
  }

once i run pnpm link --global my-module
is that clear enough?

@BlackHole1
Copy link
Member

okey

@joe-gre
Copy link

joe-gre commented Apr 4, 2023

What is the status of this? Could the linked PR be looked at?

@mikeandtherest
Copy link

@zkochan @BlackHole1 I would appreciate if we could get an update on this defect. We're currently in the process of migrating an enterprise-scale project from npm to pnpm, but this change that pnpm link --global <pkg> does on the package.json file could be a showstopper for us. Thanks!

@zkochan
Copy link
Member

zkochan commented May 7, 2023

I have checked how this works with npm. Looks like the link command never changes the package.json file in this case. So I assume the fix is really easy, we just don't have to write the package.json file.

@mikeandtherest
Copy link

Thank you for moving forward with the fix @zkochan! I can confirm that it works fine on our end with v8.5.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants