-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Yarn install --production does not remove dev dependencies #6373
Comments
Why has this issue been closed? It doesn't seem to be addressed yet. |
I believe that I closed it because Please don't kill the messenger on this one, I believe that This thread might be helpful: #696 I will reopen it and describe this as a feature request instead of a bug. |
Thanks for the clarification, I’ll just use |
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? |
I would also really like the option to remove the dev dependencies from the node modules... |
any way to prune dev dependencies using only yarn? |
Hi there, I am running into the same issue, I need to install dev dependencies to build a NextJS/TypeScript app before running it for production. So I ended up doing it in 3 steps actually as below :
I am not sure it's the best way to go... any thought on this approach please ? |
@donaminos Like a lot of people in this thread I rolled my own solution and I’ve been lurking here to not miss the silver bullet. ;-) .. I ended up with something similar to your approach. But I don’t remove node_modules before —production and I remove yarn and its cache as a final step. I wonder if removing node_modules before —production actually brings down the sizes, especially in a workspace context. Need to try this out later. Thanks for sharing :) |
Removing all node_modules folders after building/transpiling and before re-installing with —production flag (and other options noted by sibling above) reduces container image sizes of my app by roughly 5%. If you’re building from a workspace project and some workspaces aren’t needed, remove them manually. I also use a .yarnclean file in my root dir to removes some junk that isn’t required for a production build, like readmes, changelogs and the like (excluding licence statements). It also remove typescript files since I transpile to ES. Saves a significant chunk if you are using thousands of dependencies (which is .. likely.. sigh..). |
Thank you for your feedback @genox |
Closing as fixed in v2 where https://yarnpkg.com/getting-started/migration |
Hi @merceyz, I don't know if I'm wrong or not but I arrived to this thread hoping to find something similar to The only reasonable way to do this seems the solution proposed here: #696 comment Anyway, I was hoping to clarify the situation and reignite the issue in case I'm right. |
Correct, it doesn't clear the cache. For docker builds I suggest using this Yarn plugin as it was specifically made for that https://gitlab.com/Larry1123/yarn-contrib/-/tree/master/packages/plugin-production-install |
This is still an issue. Removing node_modules & running |
@mattvb91 Read the reason for why this issue was closed |
@merceyz have read them and still of the opinion that this is a bug. |
Sure it might be a bug in V1 but it has been fixed in V2 |
This comment has been minimized.
This comment has been minimized.
I'm going to close this issue as it has reached its course. In case you believe a followup work needs to be done, I suggest you to open a new dedicated issue on the 2.x tracker. Also note that as we mentioned more than a year ago (and repeatedly since then), the 1.x line will only see security fixes from our team. We're now at 2.4, on our merry way to 3.0, now is probably a good time to consider upgrading. |
Do you want to request a feature or report a bug?
BugFeature Request
What is the current behavior?
I would expect the following sequence to remove all development dependencies from the project but it does not.
If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
Yarn install && yarn install --production should be idempotent, it should not matter if I call
yarn install
beforeyarn 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 runyarn 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
The text was updated successfully, but these errors were encountered: