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 --save-dev does not infer --save #5280

Open
2 tasks done
mattpen opened this issue Aug 8, 2022 · 4 comments · May be fixed by #7233
Open
2 tasks done

[BUG] npm --save-dev does not infer --save #5280

mattpen opened this issue Aug 8, 2022 · 4 comments · May be fixed by #7233
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 8.x work is associated with a specific npm 8 release

Comments

@mattpen
Copy link

mattpen commented Aug 8, 2022

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

When I run npm install --save-dev <package-name> package.json is not modified; nothing is added to devDependencies.

Expected Behavior

I would expect that a command like npm install --save-dev <package-name> would install that package in the current directory and add the package information in package.json's devDepencies object.

Steps To Reproduce

  1. In this environment...
[~/test]$ npm -v
8.15.0
[~/test]$ node -v 
v18.7.0
[~/test]$ sw_vers
ProductName:	macOS
ProductVersion:	12.4
BuildVersion:	21F79
  1. With this config...
$ npm config list
package-lock = false 
save = false 
save-exact = false 
save-prefix = "^" 
  1. Run '...'
[~/test]$ rm -rf package.json 
[~/test]$ rm -rf node_modules 
[~/test]$ npm init -y
Wrote to /Users/matt/test/package.json:

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}


[~/test]$ npm install --save-dev mocha

added 79 packages, and audited 80 packages in 6s

20 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
[~/test]$ cat package.json 
{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}
[~/test]$
  1. See error...
    devDependencies does not exist as expected.

Environment

  • npm: 8.15.0
  • Node.js: 18.7.0
  • OS Name: macOS 12.4
  • System Model Name:
  • npm config:
package-lock = false 
save = false 
save-exact = false 
save-prefix = "^" 
@mattpen mattpen added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Aug 8, 2022
@ljharb
Copy link
Contributor

ljharb commented Aug 9, 2022

You set save to false - i wonder if that's overriding it?

@mattpen
Copy link
Author

mattpen commented Aug 9, 2022

You set save to false - i wonder if that's overriding it?

That might be it. npm i --save --save-dev <package-name> seems to work, thanks @ljharb. I assumed --save-dev would imply --save.

@ljharb
Copy link
Contributor

ljharb commented Aug 9, 2022

I think it's reasonable to assume it would, and I think it's arguable that it's a bug in npm that save-dev/save-peer/etc do not imply --save (in the same way that --package-lock-only implies --package-lock)

@wraithgar wraithgar changed the title [BUG] npm install --save-dev does not update devDependencies in package.json [BUG] npm --save-dev does not infer --save Aug 10, 2022
@wraithgar wraithgar added Priority 2 secondary priority issue and removed Needs Triage needs review for next steps labels Aug 10, 2022
ficocelliguy added a commit to ficocelliguy/cli that referenced this issue Feb 19, 2024
@ficocelliguy
Copy link

PR updated to resolve this issue: #7233

ficocelliguy added a commit to ficocelliguy/cli that referenced this issue Feb 20, 2024
ficocelliguy added a commit to ficocelliguy/cli that referenced this issue Mar 1, 2024
ficocelliguy added a commit to ficocelliguy/cli that referenced this issue Mar 5, 2024
ficocelliguy added a commit to ficocelliguy/cli that referenced this issue Mar 5, 2024
ficocelliguy added a commit to ficocelliguy/cli that referenced this issue Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants