Link Search Menu Expand Document

npm Cheat Sheet


npm list        # Show packages in local path
npm list -g     # Show global packages
npm list -g -p      # Show global packages, parseble list

npm view <package>

npm install <package>[@<version>]
npm uninstall <package>[@<version>]
npm rm <package>

npm search <something>

npm link <package>    # Link global package into user env
npm unlink <package>

npm link        # Link package into global env (when in package dir)
npm unlink


npm init        # Create new package

npm publish
npm unpublish <package>

npm adduser

npm owner add <user> <package>
npm owner rm <user> <package>
npm owner ls <package>

npm start       # Start an app

Using npm modules for clients

E.g. exposing jquery with Express:

app.use('/assets', [
    express.static(path.join(__dirname, 'node_modules', 'jquery', 'dist'))

which allows the client to fetch /assets/jquery.js.

Configure a private registry

cat <<EOF > /etc/npmrc
_auth = $(echo -n "${username}:${password}"| base64 -w0)
email = [email protected]
always-auth = true