Cli: [BUG] npm install modifies the package.json funding field

Created on 15 Oct 2020  ·  3Comments  ·  Source: npm/cli

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
Bug Needs Triage Release 7.x

All 3 comments

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

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

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"
},

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

Was this page helpful?
0 / 5 - 0 ratings