Skip to content

npm

Install

Global Config / setup

npm config list

Global installation in homdir

mkdir ~/.npm/packages
npm config set prefix ~/.npm/packages

Show root dirs:

npm root -g
npm root

Show prefix dirs:

npm prefix
npm prefix -g

Install / Upgrade npm

npm install npm@latest -g

Installation paths:

  • local: ~/node_modules/.bin/
  • global: ~/.npm-global/bin/

npm global or local packages

Install npm modules locally, not as root

Resolving EACCES permissions errors when installing packages globally

npm install mermaid.cli
~/node_modules/.bin/mmdc -h

Install from Github

npm install LinuxBozo/jsonresume-theme-kendall#main

Upgrade module

npm update turndown --depth 3

Update package-lock.json

Update package-lock.json after updating versions in package.json:

npm update --save

Audit security vulnerabilities

npm audit
npm audit fix

npx

Introducing npx: an npm package runner

Yarn

Website

Until this Debian ITP got resolved:

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo tee /etc/apt/trusted.gpg.d/yarn.asc
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update
sudo apt install yarn

Config at ~/.yarnrc