Node

« Go back to Cheatsheets

Initialization

1
2
# prompt to create your package.json file
  npm init

Install, Uninstall

1
2
3
4
5
6
7
8
# install packages listed in package.json file
  npm install

# install a node package
  npm install -g <package-name>

# uninstall a package
  npm uninstall -g <package-name>

Start

1
2
# start the node server
  npm start

Link Folder

1
2
3
4
5
6
# testing your node plugin in local
  # in cloned location
  npm link

  # in testing location
  npm link package-name

Publish package to NPM

1
2
# publish your package to npm, version number update in package.json is required
  npm publish

Faster NPM Install

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# setting progress true (slower installation)
  npm set progress=true
  rm -rf node_modules
  time npm install
  npm install 185.85s user 45.15s system 107% cpu 3:35.28 total

# setting progress false (faster installation)
  npm set progress=false
  rm -rf node_modules
  time npm install
  npm install 99.79s user 37.20s system 120% cpu 1:53.74 total

# set progress to false in default config
  npm config set progress=false

Clear & Do fresh install

1
npm cache clear && rm -rf node_modules && npm install

Comments