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

Do not install developer dependencies for NodeJS #2483

Closed
mattyclarkson opened this issue Aug 15, 2022 · 8 comments
Closed

Do not install developer dependencies for NodeJS #2483

mattyclarkson opened this issue Aug 15, 2022 · 8 comments

Comments

@mattyclarkson
Copy link

search tried in the issue tracker

dev node

describe your issue

The NodeJS language install command uses --dev (which should be --include=dev, #1983) to install packages. This is unneeded.

Packages only require the production (dependencies) installed. Any package that is requiring the developer dependencies to be installed to operate is broken.

If a package is using peerDependencies then additional_dependencies should be used to install them.

This is an issue when installing NPM modules when the developer dependencies are of significant size. The pre-commit users have to sit through a lengthy download session when warming up the pre-commit cache. The downloaded dependencies are unused once installed.

pre-commit --version

pre-commit 2.17.0

.pre-commit-config.yaml

# any config that installs NPM modules

~/.cache/pre-commit/pre-commit.log (if present)

No response

@asottile
Copy link
Member

this was the command recommended by the npm developers

a common example is when a tool uses typescript

@mattyclarkson
Copy link
Author

Ah, because we're installing directly from git and there are build steps, gottit.

Is there any interest in making that configurable as part of the install?

@asottile
Copy link
Member

no it shouldn't be configurable -- though deleting ./node_modules after install should be safe if you'd want to pursue that instead

@mattyclarkson
Copy link
Author

Hmm, it's installing optional dependencies which are the big ones.

Seems --omit=optional is needed to avoid that.

NPM 6 uses --no-optional which is still supported on the later NPM.

Any interest in adding --no-optional to the install command?

@asottile
Copy link
Member

this is the actual relevant install command:

install = ('npm', 'install', '-g', pkg, *additional_dependencies)

the command you're referring to is so pack can succeed and is the one that the npm developers recommended to us

@mattyclarkson
Copy link
Author

mattyclarkson commented Aug 15, 2022

Yep, the previous command is the one that is installing all the optional dependencies.

Oh, I see. OK, I'll need to debug what is going on then.

I'm pretty sure we can work around this with npm workspaces.

@asottile
Copy link
Member

I'm pretty sure all you need to do is submit a patch to delete ./node_modules after the -g install -- it shouldn't be relevant / used after that point

@asottile
Copy link
Member

but you'll need to do some research to make sure that's safe as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants