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

[BUG] npm install modifies the package.json funding field #1964

Closed
jaydenseric opened this issue Oct 15, 2020 · 5 comments
Closed

[BUG] npm install modifies the package.json funding field #1964

jaydenseric opened this issue Oct 15, 2020 · 5 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release

Comments

@jaydenseric
Copy link

Current Behavior:

Running npm install with npm v7 undesirably modifies the package.json funding field from a URL string, to an object with a url property.

Expected Behavior:

Running npm install should not modify a valid format for the package.json funding field.

Steps To Reproduce:

  1. In package.json, add a funding field with a URL string as a value.
  2. In the project, run npm install.

Notice the resulting change to package.json, e.g:

-  "funding": "https://github.com/sponsors/jaydenseric",
+  "funding": {
+    "url": "https://github.com/sponsors/jaydenseric"
+  },

Environment:

  • Node.js: v14.13.1
  • npm: v7.0.0
@jaydenseric jaydenseric added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Oct 15, 2020
@billyjanitsch
Copy link

billyjanitsch commented Oct 22, 2020

It also modifies the bin field, e.g.:

 {
   "name": "foo",
-  "bin": "bar.js"
+  "bin": {
+     "foo": "bar.js"
+   }
 }

@Farfurix
Copy link

Farfurix commented Oct 27, 2020

I have a similar issue with using relative paths in the "bin" field.
My steps (npm v7.0.5):

  1. Run npm init -y
  2. Add the "bin" field with some relative path:
"bin": {
  "foo": "./bin/bar.js"
},
  1. Run npm i
  2. Result:
"bin": {
-   "foo": "./bin/bar.js"
+   "foo": "bin/bar.js"
},

@ljharb
Copy link
Collaborator

ljharb commented Oct 27, 2020

If anything, it should include the ./ - but ideally it wouldn't modify the field value at all.

@sindresorhus
Copy link

@ruyadorno Any chance you would be able to look into this? Anyone using my np tool to publish packages are unable to use npm v7 because np runs npm install when publishing and since that modifies package.json, the Git dirty check fails and so the whole publish fails.

ruyadorno added a commit to npm/arborist that referenced this issue Nov 24, 2020
Currently, bin and funding values from the root package.json file are
being normalized when reifying. This changes it to avoid overriding
bin/funding shorthands and always use the original values instead of
their normalized results when writing to the root package.json file.

Fix: npm/cli#1964
ruyadorno added a commit to npm/arborist that referenced this issue Nov 24, 2020
Currently, bin and funding values from the root package.json file are
being normalized when reifying. This changes it to avoid overriding
bin/funding shorthands and always use the original values instead of
their normalized results when writing to the root package.json file.

Fix: npm/cli#1964
ruyadorno added a commit to npm/arborist that referenced this issue Nov 25, 2020
Currently, bin and funding values from the root package.json file are
being normalized when reifying. This changes it to avoid overriding
bin/funding shorthands and always use the original values instead of
their normalized results when writing to the root package.json file.

Fix: npm/cli#1964
ruyadorno added a commit to npm/arborist that referenced this issue Nov 25, 2020
Currently, bin and funding values from the root package.json file are
being normalized when reifying. This changes it to avoid overriding
bin/funding shorthands and always use the original values instead of
their normalized results when writing to the root package.json file.

Fix: npm/cli#1964
@ruyadorno
Copy link
Collaborator

Fixed in 7.0.15 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants