Simple Guides for JS Tools: Package Managers

One day, you will begin developing on not a greenfield or from-the-scratch project and this time will be the moment you are going to start looking at the conversions between package managers.

Let’s assume that you develop sth. on a system established between bower packages and your boss expects from you to update more efficient and performant way. This time will be the time to choose the best for your and your team. Here are the first part of Simple Guide for JS Tools series: Package Managers.

npm

Comes with your local Node.js installation. Nearly every packages are here and stored for your first fetch.

Check the version: npm -v

Create package: npm init

Install package: npm i <package-name> or npm i <package-name>@<package-version> eg. npm i somePackage or npm i somePackage@1.1.3

Install all local packages: npm i or npm install

Add yourself within the package as the author: npm adduser (prompts user name and password) or npm login will work the same.

Check if the credentials are there: npm config ls

Send your package to npm: npm publish

After changes you do: npm version <major.minor.patch> .eg npm version 1.1.3

Update local packages: npm update

Remove dependency: npm uninstall <package-name>

The reference page of that <package-name> is here: www.npmjs.org/package/package-name

yarn

Install yarn: brew install yarn

Add yarn into your local profile: export PATH=”$PATH:/opt/yarn-[version]/bin”

create package: yarn init

install package: yarn add<package-name>

Install all local packages: yarn or yarn install

Add yourself within the package as the author: npm adduser (prompts user name and password) or npm login will work the same.

Check if the credentials are there: yarn config list

Login into yarn: yarn login

Send your package to npm: yarn publish

After changes you do: yarn version <major.minor.patch> .eg yarn version 1.1.3

Update local packages: yarn upgrade <package-name> or yarn upgrade <package-name>@<version-number>

Remove dependency: yarn remove <package-name>

The reference page of that <package-name> is [here](https://yarnpkg.com/en/package/<package-name>).

pnpm

Install: npm i pnpm -g

pnpm is like a custom npm with a performant way of storing packages. If you have a number of copies of modules on disk, it uses symlinks into your node_modules directory to have the package used from only one version.

It uses npm api also and override npm install and some other commands for performance gain. You may ask now why pnpm almost uses the “node_modules” directory if everything is global. Just look at [here](https://github.com/pnpm/pnpm#frequently-asked-questions).

Install pnpm: npm i pnpm -g

Install package: pnpm install <package-name>

ied

Another competitor for npm.

Install ied: npm i ied -g

Check the version: ied -v

Create package: ied init

Install package: ied install<package-name> or ied i <package-name>@<package-version> eg. ied install somePackage or ied install somePackage@1.1.3

Install all local packages: ied install

Other commands may be used via npm.

The commands reference page is here: https://github.com/alexanderGugel/ied/blob/master/USAGE.txt

bower

The old boy for Javascript world ;)

Install bower: npm i bower -g

Check the version: bower -v

Login into bower: bower login

Create package: bower init

Install package: bower install<package-name> eg. bower install somePackage

Register packages with git repos (Pushing sources to the remote): bower register <package-name> <gith-repo-url>

Search for packages: bower search <package-name>

The commands reference page is [here](https://bower.io/docs/api/).

The next part of the series will be about task managers/runners.