/npm-vs-yarn

npm vs yarn install speed testing.

Primary LanguageDockerfileMIT LicenseMIT

npm-vs-yarn

Npm vs Yarn install speed testing.

What is Yarn

Yarn is a new package manager for JavaScript. Please read blog post from Facebook for detail information.

Prepare Environment

You can testing in Docker or what you prefer.

  • node version: v10.11.0
  • npm verison: 6.4.1
  • yarn verison: 1.9.4

Testing without cache

Testing install speed without cache node_modules folder.

$ rm -rf ~/.npm/_cacache/
$ time npm install

time: 3m40.155s

Try npm ci command

$ rm -rf ~/.npm/_cacache/
$ time npm ci

time: 3m10.783s

$ yarn cache clean
$ time yarn install

time: 1m1.261s

Testing with cache

Testing install speed without include cache node_modules folder.

$ rm -rf node_modules
$ time npm install

time: 1m1.195s

Try npm ci command

$ rm -rf node_modules
$ time npm ci

time: 0m18.030s

$ rm -rf node_modules
$ time yarn install

time: 0m30.571s

Testing install speed with cache node_modules folder.

$ time npm install

time: 0m54.944s

$ time npm ci

time: 0m21.810s

$ time yarn install

time: 0m2.109s

Conclusion

Date: 2018-10-02

Yarn is faster than npm. We can move package manager from Npm to Yarn for JavaScript now.

npm install npm ci yarn
install without cache (without node_modules) 3m 3m 1m
install with cache (without node_modules) 1m 18s 30s
install with cache (with node_modules) 54s 21s 2s
install without internet (with node_modules) - - 2s