An NPM cheatsheet


npm install -g npm

Installing specific versions

npm install jquery@1.10.2

Checking which version is loarded

npm view <package> versions

Install components from package.json

npm install

Run the dev server with hot reload at localhost:8080

npm run dev

View installed packages that are outdated / could be upgraded

npm outdated


npm uninstall vue-model
npm install vue-model

Reinstall specific version

npm install vue-model@0.3.0

Install from github

npm install aarondfrancis/vue-model

Build the app for production

npm run build

 List locally installed packages

npm list
npm list --depth=0 // without dependencies

List globally installed packages

npm list -g

Clear cache

npm cache clean

Creating a package.json

npm init

Package.json versioning (tilde / caret etc)

~version "Approximately equivalent to version" See npm semver - Tilde Ranges & semver (7)
^version "Compatible with version" See npm semver - Caret Ranges & semver (7)
version Must match version exactly
>version Must be greater than version
>=version etc
1.2.x 1.2.0, 1.2.1, etc., but not 1.3.0
http://sometarballurl (this may be the URL of a tarball which will be downloaded and installed locally
* Matches any version

Fixing Sass

Module build failed: Error: Node Sass does not yet support your current environment: Linux 64-bit with Unsupported runtime

run npm rebuild node-sass

Error: pngquant failed to build, make sure that libpng-dev is installed

yum install libpng-devel