-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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 'installing' devDependencies of my dependency when there is script "build" #3902
Comments
Hi @dhpagani any luck with that? I've the same issue |
@leobel about this, not yet... I've not updated my projects to use the newest version yet, but I'm considering to change to another package manager, like yarn ou pnpm. |
We also have this issue. We publish our private packages to GitHub to make dev setup easier (no need to set up auth for both GitHub and some private NPM registry). We publish the transpiled code to a different branch in our repos and tag with the appropriate semver tag. We deliberately don't have a The problem appears to be in https://github.com/npm/pacote/blob/2ddf67f7c4e084ffec315f94e30bb24f944403e3/lib/git.js#L153 It look as if any of the following scripts will cause installation of dev dependencies:
The documentation only seems to mentions the Can anyone from NPM please tell us whether this is a deliberate change in behaviour (and should be documented) or whether this is a regression? |
+1 |
We've just come across this when upgrading from Node.js 14 to 16. For now, we've worked around it by downgrading Our experience is pretty similar to @dhpagani - we're installing a dependency which has a Are there any updates on this? Thanks! |
this is expected behavior, if you have a git dependency with a if you've already pre-built your package and the build artifacts are stored in the git repository, the correct thing to do here is rename your |
I got your point, but I didn't find in the docs about that assumption. I've check in the scripts lifecycle (https://docs.npmjs.com/cli/v8/using-npm/scripts) and in the reference of git dependencies(https://docs.npmjs.com/cli/v8/configuring-npm/package-json#git-urls-as-dependencies) In my opinion, this assumptions (and others) must be better explained or referenced. What do you think? |
i do agree it needs more documentation. i'm making some other edits today and i'll clarify that while i'm in there. good suggestion! |
@nlf this opinion would carry much more weight if npm install --verbose paulbrimicombe/npm-git-deps-testing#semver:^4.0.0 This package has Do I take it from your comment that the
How do package owners know that they have to do this if there is absolutely nothing in the documentation to let them know of this change? The |
There are projects such as ramda that publish built and minified artefacts alongside their source code. Executing the project's It seems to me that NPM has always been explicit about the purpose and position in lifecycles of script hooks, and the installation of development dependencies due to any number of pre or post install, build and even prepare scripts will be unexpected behaviour to many. For this reason it should be worth considering whether the current behaviour is desired as it is both implicit and default. Could you consider providing an opt-in explicit script hook as you do for all other behaviour? This would allow authors who did want the consumer of a package to build their project and would not break the projects of those who do not. |
I see this was closed recently but I want to contribute. I have a project (github.com/EnCiv/undebate-ssp) that includes other repos (github.com/EnCiv/undebate, github.com/EnCiv/civil-server, github.com/EnCiv/civil-client). Each project includes devDependencies like storybook, jest, lint. These cause a tremendous load on the build process and time, When I set NPM_CONFIG_PRODUCTION=true then it doesn't try to load the devDependencies of .undebate-ssp but it seems to still load and build the devDependencies of the child repos. Beside the tremendious amount of time this takes, when I try to push the project to heroku - it stalls. I think that npm has fired off so many things in parallel that it just locks up. I would like to point out that there are buildDependencies (like babel) and there are testDependencies (jest) the testDependencies of repos don't need to be loaded or built, expcept in the root - top level build (undebate-ssp). I've seen a lot of discussion about how devDependencies should be enough. But I want to point out that all the machine cycles and network bandwidth spent on testDependencies is wasted electricity and people's time. And in some cases the project won't build. I wish that:
Please let me know if I should start a new issue for this, or post it somewhere else. Thanks. |
otherwise npm is always trying to install all devDependencies and build the project - see npm/cli#3902 Signed-off-by: Artem Kozlov <[email protected]>
Is there an existing issue for this?
Current Behavior
NPM is trying to install the devDependencies from my dependency just because there is a script in package.json named "build".
It didn't put this devDependency in node_modules and I only notice that because my scenario node-sass is present and fail to install.
In a scenario of pkgA and pkgB
pkgA: https://github.com/dhpagani/npm-bug-pkga/
Create a new project pkgB and add pkgA as a git dependency. Try to run
npm install
on pkgb and, (if your env is not prepared to install node-sass) you will see an error of node-sass postinstall script.Expected Behavior
Running
npm install
in pkgb, it didn't try to install node-sass (as a transitive devDependencies) of my library.Steps To Reproduce
Create a git dependency:
If I use this dependency in any project, like:
and run
npm install
on pkgb, I received a log of postinstall script from node-sass failing (which is a transitive dependency of grunt-sass). If it didn't fail, I wouldn't notice this behavior.If I change the name of the "build" script (to something like build2), run
install
again, it won't try to install node-sass.In any scenario, like removing grunt-sass and put other dependency, the script "build" didn't run.
Environment
Maybe related to #3800
The text was updated successfully, but these errors were encountered: