Yarn: Yarn install --production does not remove dev dependencies

Created on 9 Sep 2018  路  6Comments  路  Source: yarnpkg/yarn

Do you want to request a feature or report a bug?

~Bug~
Feature Request

What is the current behavior?
I would expect the following sequence to remove all development dependencies from the project but it does not.

yarn install
yarn install --production

If the current behavior is a bug, please provide the steps to reproduce.

git clone https://github.com/ajhool/yarn-dependency-behavior.git
cd yarn-dependency-behavior
yarn install //moduleD only has devDependencies so ./packages/moduleD/node_modules is populated.
yarn install --production // observe that ./packages/moduleD/node_modules is still populated despited only include devDependencies.

What is the expected behavior?
Yarn install && yarn install --production should be idempotent, it should not matter if I call yarn install before yarn install --production

If the current behavior is expected, then perhaps an explicit statement in the yarn install --production documentation or an execution-time warning would be helpful. A lot of people simply run yarn install --production before zipping and deploying their code.

Please mention your node.js, yarn and operating system version.
Node 8.6.0
MacOS 10.12.6
Yarn 1.9.4

triaged

Most helpful comment

Does yarn have a way to prune package for production, though? For build scenarios it seems a fairly straightforward behaviour: install all dependencies (including dev for stuff like gulp or whatever), perform build, remove dev dependencies and voila.

For a 100% yarn-based process, seems like this fairly basic behaviour is missing so I have a choice between either removing the folder and reinstall or replicating yarn configuration for npm as well to be able to prune (since in my case I'm installing to a custom folder specified in yarnrc which NPM doesn't know about). In which I might as well just use npm.

I do think the behaviour described in the initial report is desirable.

All 6 comments

Why has this issue been closed? It doesn't seem to be addressed yet.

I believe that I closed it because yarn install --production is not designed to prune out dev dependencies. It is only supposed to install the production dependencies. yarn install --production is a subset of yarn install and calling yarn install --production after calling yarn install should have no effect.

Please don't kill the messenger on this one, I believe that yarn install --production should prune out the dev dependencies, but I don't believe that the yarn authors intended for that behavior.

This thread might be helpful: https://github.com/yarnpkg/yarn/issues/696

I will reopen it and describe this as a feature request instead of a bug.

Thanks for the clarification, I鈥檒l just use npm prune --production for now...

Does yarn have a way to prune package for production, though? For build scenarios it seems a fairly straightforward behaviour: install all dependencies (including dev for stuff like gulp or whatever), perform build, remove dev dependencies and voila.

For a 100% yarn-based process, seems like this fairly basic behaviour is missing so I have a choice between either removing the folder and reinstall or replicating yarn configuration for npm as well to be able to prune (since in my case I'm installing to a custom folder specified in yarnrc which NPM doesn't know about). In which I might as well just use npm.

I do think the behaviour described in the initial report is desirable.

If this is not a bug, then shouldnt this page be updated?
https://classic.yarnpkg.com/en/docs/cli/prune/

I would also really like the option to remove the dev dependencies from the node modules...

Was this page helpful?
0 / 5 - 0 ratings