Node.js, npm, npx, yarn - huh?
What you will build/learn
This Codelab includes concepts/tools explanation and code snippets. To keep it simple, I have tried my best to explain things in the easiest way possible. Also, I have added some GIFs so that you can see those snippets in action.
Scope & Preferred for:
This Codelab has been designed especially for those who are just beginning with Node and have some confusion about buzz words like npm, npx, node etc.
Things you will learn
Tools you will require
- A computer/laptop with an internet connection.
What is Yarn?
Yarn is another package manager, an alternative to npm. It was built by developers at Facebook while Npm, Inc. (A Github owned organisation) is behind npm.
Yarn Vs NPM
When Yarn started, it had many better things to offer than npm. It was fast, secure, lock file and much more but now in 2021, it just comes down to developer preference. Both are fast, secure and provide almost the same features. Just one difference - Yarn maintains a flat dependency tree while npm maintains the nested one.
If confused just go with npm or try both. 😜
How to install Yarn?
npm install -g yarn
How to install a package from npmjs.com using Yarn?
yarn add date-fns
Yes, that same package but installation using Yarn instead of npm.
Any other package manager that worth knowing?
There are many other package managers other than `npm` and `yarn` but recently many are adopting pnpm. It's worth checking it.