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] DevDependancy are installed in production when also marked as peerDependenciesMeta optional #7734

Closed
2 tasks done
saziri-arrow opened this issue Aug 19, 2024 · 3 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps

Comments

@saziri-arrow
Copy link

saziri-arrow commented Aug 19, 2024

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

Hello,

I have an unexpected behaviour between peerDependencies, peerDependenciesMeta and devDependencies.

I have a library with a package.json with a peerDependancy (example with typeorm) :

"dependencies": {
"typeorm": "^0.3.2"
}

typeorm has ts-node as a peerDependacy optional : https://github.com/typeorm/typeorm/blob/master/package.json#L216

When I run npm install --omit=dev, ts-node and typescript are not installed (correct behavior)

Now I also add ts-node as a devDependancy since I want to use it in my unit tests :
"devDependencies": {
"ts-node": "^10.9.2"
},

Now, when I run npm install --omit=dev, typescript package is installed (wrong behavior)

Tried with npm 9.8.1, and 10.8.1

Issue happen with any library.
Any projet who has 'ts-node' as a devDependancy and use typeorm will have typescript installed in production

Can you fix this issue ?

Expected Behavior

ts-node should not be installed with npm install --omit=dev

Steps To Reproduce

run npm install --omit=dev with the example ahead

Environment

  • npm:
  • Node.js: 20.16.0
  • Npm : 10.8.1 (also happen with 9.8.1)
  • OS Name: 14.3.1
  • System Model Name: MacOS
@saziri-arrow saziri-arrow added Bug thing that needs fixing Needs Triage needs review for next steps labels Aug 19, 2024
@saziri-arrow saziri-arrow changed the title [BUG] DevDependancy are install in production when also marked as optional peer [BUG] DevDependancy are installed in production when also marked as peerDependenciesMeta optional Aug 19, 2024
@milaninfy
Copy link
Contributor

@saziri-arrow I could see that, There might a typo in the command you are running npm install --omit-dev, can you try changing it npm install --omit=dev ?

for me the behaviour seems correct.

for this package.json which resembles your test case

{
  "name": "rep",
  "version": "1.0.3",
  "peerDependencies": {
    "lodash": "4.17.21"
  },
  "devDependencies": {
    "lodash": "4.17.21"
  },
  
  "peerDependenciesMeta": {
    "lodash": {
      "optional": true
    }
  }
}

As you can see from the log the lodash is missing after running npm install --omit=dev

~/workarea/rep $ npm install --omit=dev

up to date, audited 1 package in 3s

found 0 vulnerabilities
~/workarea/rep $ npm ls
rep@1.0.3 /Users/milaninfy/workarea/rep
└── UNMET DEPENDENCY lodash@4.17.21

npm error code ELSPROBLEMS
npm error missing: lodash@4.17.21, required by rep@1.0.3
npm error A complete log of this run can be found in: /Users/milaninfy/.npm/_logs/2024-08-19T14_16_19_901Z-debug-0.log

@saziri-arrow
Copy link
Author

saziri-arrow commented Aug 19, 2024

Hello @milaninfy thank you for your fast answer! Indeed I made a mistake in my first explanation... I edit it and now the problem appears with --omit=dev still. Please test again

@saziri-arrow
Copy link
Author

Screenshot 2024-08-19 at 18 02 13

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
Projects
None yet
Development

No branches or pull requests

2 participants