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

bring back --only=dev and --only=prod for npm v7 #2028

Open
isaacs opened this issue Oct 23, 2020 · 6 comments
Open

bring back --only=dev and --only=prod for npm v7 #2028

isaacs opened this issue Oct 23, 2020 · 6 comments
Labels
Enhancement new feature or improvement Release 7.x work is associated with a specific npm 7 release

Comments

@isaacs
Copy link
Contributor

isaacs commented Oct 23, 2020

npm v7 always installs production deps. There's no way to omit them. We should bring this back, and let you do --omit=prod as well.

@darcyclarke darcyclarke added Release 7.x work is associated with a specific npm 7 release Enhancement new feature or improvement Bug thing that needs fixing labels Oct 30, 2020
@darcyclarke darcyclarke added this to the OSS - Sprint 23 milestone Feb 2, 2021
@darcyclarke darcyclarke added the Priority 1 high priority issue label Feb 2, 2021
@wraithgar
Copy link
Member

From #1969 (comment)

Agreed, this is wasteful.

Note for implementer: add a check for the omit settings in the _problemEdges method here: https://github.com/npm/arborist/blob/main/lib/arborist/build-ideal-tree.js#L831

@wraithgar
Copy link
Member

from #1969 (comment)

When is use npm install with --only=prod arguments, i just want npm only fetch module in dependencies.
but currently, npm fetch all module information, it's make install process slow.

@wraithgar wraithgar changed the title bring back --only=dev for npm v7 Feb 3, 2021
@isaacs
Copy link
Contributor Author

isaacs commented Feb 3, 2021

Note: if omit includes prod, then we can't just omit all nodes where devOptional/peer are false, because devDeps can depend on production deps. Omitting production is pretty tricky. One approach might be to add yet another flag in calcDepFlags to indicate "yes, I'm production, but I'm a transitive or direct dependency of dev/optional/peer nodes". Otherwise we'll have to walk out from the node's edgesIn to see if there are any non-production nodes in the set.

Updated _problemEdges link: https://github.com/npm/arborist/blob/3b02f76c691def829e7d26ba0d52989a07e37390/lib/arborist/build-ideal-tree.js#L927

Also, since we still have to resolve dev deps for the purpose of building the ideal tree/shrinkwrap, even if they're not being installed, it may be that the "don't fetch devDep manifests in --only=prod mode" is just a wontfix.

@xqin
Copy link

xqin commented Feb 3, 2021

If only this is the case(about won't fix), does it mean that if I want to achieve such an effect, I can only delete the corresponding node in package.json before executing npm install?

@xqin
Copy link

xqin commented Feb 3, 2021

I have been tracking this issue for many years. If this is the final result (no need to fix), for the npm community, I don't know what to say.

this issue exists since npm v5.10.0 and still exists in npm 7.

@sandstrom
Copy link

sandstrom commented Feb 9, 2022

Ability to install only dev-dependencies, or only production-dependencies, would be great.

What would be even better, is if we could make arbitrary groups in the package.json file, and only install one or several groups. A few group examples would be 'production', 'development', 'linting', 'continuous-integration', …

A good use-case for this is to have a linting group that's only installed during certain CI-runs. On the tree (in package-lock.json, you could have e.g. "groups" : ["dev", "prod", "linting"] instead of the current "dev": true flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement new feature or improvement Release 7.x work is associated with a specific npm 7 release
5 participants