Do you want to request a feature or report a bug?
bug
What is the current behavior?
yarn prune v1.13.0
error The prune command isn't necessary. `yarn install` will prune extraneous packages.
info Visit https://yarnpkg.com/en/docs/cli/prune for documentation about this command.
^ This is a lie.
If the current behavior is a bug, please provide the steps to reproduce.
mkdir -p node_modules/foo
cd node_modules/foo
npm init
cd ../..
npx [email protected] install
node_modules/foo will still be there
In contrast yarn install --force does remove node_modules/foo.
What is the expected behavior?
You tell me? Either docs should be updated or behaviour of yarn install changed.
According to docs yarn install should prune unnecessary deps.
Why:
I had in project 2 dependencies having foo as dependency. One was pointing to foo as dependency and the other was pointing as optionalDependency. I got rid of one with dependency and I'm using ----ignore-optional on deployment. The thing is the foo dependency wasn't really optional but I detected it a little too late because I still had stale foo in node_modules.
If docs were honest I would simply run rm -rf node_modules before yarn install on deployments to ensure such things don't happen again.
Please mention your node.js, yarn and operating system version.
node 6.14.3, yarn 1.13.0 and macOS sierra
Interesting. Yarn has an optimization mechanism that will simply not run the install if it detects that your package.json didn't change. Meaning that when running yarn && yarn, the second one will bailout.
In this case (reproduced by yarn add lodash, removing lodash from the package.json, then running yarn again), it seems there's a bug and Yarn doesn't properly detect that the package disappeared, causing it to bailout instead of running the install. That's weird, I could have sworn it worked before 馃
Any updates on this?
Confirmed this with
Removing entries from package.json then running yarn install doesn't remove the packages at all
I think there's also some merit to keeping the current behavior as is, i.e. many node packages stuff additional folders into node_modules that can be safely kept (e.g. angular's ngcc) between installations.
If you need to prune, you can always run yarn prune manually, no?
Edit: You're absolutely right about the docs being misleading though
The yarn prune command simply aborts with the error message shared in the original report and didn't seem to have any obvious effect for me. Resorting to yarn install --force instead is not especially obvious. If a standard yarn install run is not going to clean up going forward, a working yarn prune command would be helpful.
Please provide a working yarn prune since the implied behaviour of yarn install clearly isn't reliable.
On our CI we cache the node_modules manually and extract the latest cache before running yarn install to install any potentially missing packages.
If manually doing rm -rf node_modules before installing the size is 1.1GB. Meanwhile the cached node_modules directory has bloated to ~2GB.
Running yarn prune currently exits immediately with:
yarn prune v1.22.4
error The prune command isn't necessary. `yarn install` will prune extraneous packages.
info Visit https://yarnpkg.com/en/docs/cli/prune for documentation about this command.
Most helpful comment
Please provide a working
yarn prunesince the implied behaviour ofyarn installclearly isn't reliable.On our CI we cache the
node_modulesmanually and extract the latest cache before runningyarn installto install any potentially missing packages.If manually doing
rm -rf node_modulesbefore installing the size is 1.1GB. Meanwhile the cachednode_modulesdirectory has bloated to ~2GB.Running
yarn prunecurrently exits immediately with: