Do you want to request a feature or report a bug?
This is a bug, I think. #990 and #3234 seem to suggest I should make a new issue.
There's a pretty good chance I've missed some simple fixes. I'm hoping that's the case.
What is the current behavior?
When installing, yarn add grabs everything and always links everything. I've built a repo to duplicate the issue. For example,
$ cd npm-small
$ npm install moment
added 1 package in 2.863s
$ npm install fs-extra
added 4 packages in 1.351s
$ cd yarn-small
$ yarn add --cache-folder=../yarn-cache moment
Done in 2.82s.
$ yarn add --cache-folder=../yarn-cache fs-extra
Done in 2.03s.
$ cd npm-large
$ npm install @angular/cli
added 994 packages in 142.135s
$ npm install fs-extra
added 116 packages and updated 1 package in 18.505s
$ cd yarn-large
$ yarn add --cache-folder=../yarn-cache @angular/cli
Done in 207.14s.
$ yarn add --cache-folder=../yarn-cache fs-extra
Done in 105.35s.
What is the expected behavior?
Not that?
Please mention your node.js, yarn and operating system version.
From my repo:
bash:
$ yarn -v
1.3.2
$ node -v
v8.9.3
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Codename: xenial
$ asciinema --version
asciinema 1.4.0
PowerShell:
> conemu-cyg-64.exe --version
ConEmu cygwin/msys connector version 1.2.2
> wslbridge.exe --version
wslbridge 0.2.3
> Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' | Select-Object ProductName, CurrentMajorVersionNumber, CurrentMinorVersionNumber, ReleaseId, CurrentBuild, CurrentBuildNumber, BuildLabEx
ProductName : Windows 10 Pro Insider Preview
CurrentMajorVersionNumber : 10
CurrentMinorVersionNumber : 0
ReleaseId : 1709
CurrentBuild : 17025
CurrentBuildNumber : 17025
BuildLabEx : 17025.1000.amd64fre.rs_prerelease.171020-1626
@thecjharries, thanks for raising this.
Yarn add command may take roughly the same time as a fresh install command that is because yarn may rebuild the node_modules structure when changing dependencies.
Still 207.14s for @angular/cli vs npm's 142.135s is a good data point.
As a general suggestion to see if Windows Defender is interfering with install, open Task Manager during install and see if Windows Defender or Indexing Service is getting high CPU usage.
Raising attention to @BYK regarding performance.
I was able to solve my issue by moving to a better operating system. However, I doubt everyone will have that luxury.
Thanks for the response, @bestander! So Yarn has to rebuild node_modules each time a package is added? Is that, in combination with Windows Defender, responsible for the ~100s install time for the second package?
So Yarn has to rebuild node_modules each time a package is added
In the worst case scenario, yes.
In most cases it should not be a problem because packages in node_modules don't usually get rearranged if you add a dependency.
However Yarn would run through all node_modules and check if something might have corrupted the files, so expect a bunch of io read operations.
Is that, in combination with Windows Defender, responsible for the ~100s install time for the second package?
I suppose when Yarn checks that all other files in node_modules are not modified it does a bunch of IO reads that Windows Defender might find suspicious and passes it through an antivirus.
Good that you found a solution
I'm actually using yarn in the ubuntu environment on windows, and I'd like to see this fixed, as I'm planning to use this setup for the foreseeable future.
Is there any update on this? I'm using Linux Subsystem on Windows and it takes about 5-10 mins to remove and then add a dependency.
Same here, around 5 minutes to add a package.
Linux Subsystem for Windows 10
➜ yarn -v
1.5.1
➜ node -v
v9.4.0
➜ npm -v
5.8.0
➜ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Codename: xenial
Using the --verbose flag with yarn add I'm seeing that it is taking most of the time copying the files from the cache to node_modules.
@iskilled can you share your package.json and yarn.lock files?
Sure.
package.json
yarn.lock
To be clear... this issue affects WSL/Bash, correct? Because that's what I'm experiencing now. Not sure if cmd.exe performs any better.
Any update on this?
Im stucked with this problem too. Trying to make yarn install and sometimes getting
error An unexpected error occurred: "ENOENT: no such file or directory, copyfile
Related to .cache/yarn/v4 and WSL Ubuntu.
My yarn version is 1.13.0
Add these exclusions to your defender in control panel.
Go to Windows Security / Virus and Threat protection, Virus and Threat Protection Settings, then choose Exclusions.
Add these two folders.
The Node.js folder is located at: c:\Program Files\nodejs and lastly the yarn global folder is at: c:\Users\YourUserName\AppData\Local\Yarn
Most helpful comment
I'm actually using yarn in the ubuntu environment on windows, and I'd like to see this fixed, as I'm planning to use this setup for the foreseeable future.