This content originally appeared on DEV Community 👩💻👨💻 and was authored by Arafat
Bookmark this article If you are migrating from npm
to yarn
or viceversa😊.
Here is a list of all commonly used commands in NPM and Yarn:
Command | NPM | Yarn |
---|---|---|
Initializing a project |
npm init |
yarn init |
Running tests for the current package |
npm test |
yarn test |
Confirming if any package is outdated |
npm outdated |
yarn outdated |
Publishing a package |
npm publish |
yarn publish |
Running a script |
npm run |
yarn run |
Cleaning the local package cache |
npm cache clean |
yarn cache clean |
Logging in and out |
npm login (logout) |
yarn login (logout) |
Installing dependencies |
npm install |
yarn |
Installing packages |
npm install [package-name] |
yarn add [package-name] |
Uninstalling packages |
npm uninstall [package-name] |
yarn remove [package-name] |
updating |
npm update |
yarn upgrade |
updating package |
npm update [package-name] |
yarn upgrade [package-name] |
Installing package globally |
npm install --global [package-name] |
yarn global add [package-name] |
Uninstalling package globally |
npm uninstall --global [package-name] |
yarn global remove [package-name] |
Interactively updating dependencies |
npm run upgrade-interactive |
yarn upgrade-interactive |
Running packages without downloading |
npx |
yarn dlx |
Checking licenses of dependencies |
N/A |
yarn licenses ls |
Conclusion
In most cases, you will only need some of these commands. However, Getting an idea of all of these commands is always a plus point. This list will help you remember easily and in migrating for you and your teams. If you feel I forgot any essential commands, please let me know in the comment section.
Thanks for reading this article from start to end. I will see you all in my next article👨💻.
This content originally appeared on DEV Community 👩💻👨💻 and was authored by Arafat
Arafat | Sciencx (2023-02-21T17:28:07+00:00) NPM & Yarn: A CLI Comparison. Retrieved from https://www.scien.cx/2023/02/21/npm-yarn-a-cli-comparison/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.