Skip to content

Instantly share code, notes, and snippets.

@jasonlucas907
Last active December 7, 2017 20:31
Show Gist options
  • Save jasonlucas907/034cfad6b308a0982cda1b23f0c539e7 to your computer and use it in GitHub Desktop.
Save jasonlucas907/034cfad6b308a0982cda1b23f0c539e7 to your computer and use it in GitHub Desktop.

NPM - Node Modules docs.npmjs.com

List all commands

npm

Global Install

npm install package-name -g

Local install

npm init

-This will create the package.json for your project.
-This will prompt questions in the terminal to set up your package.json

npm package-name —save

-This will install the nam package to your projects node modules and package.json

Require on project

Require in project example in app.js

var example = require(‘example’)

Gitignore

Create a .gitignore file in the root directory and include file to ignore.

example: node_modules/

Install dev dependency

These are modules needed in development and not to run the website in production. Example: testing frame works

npm install package-name —save-dev

Update

npm outdate

-This will show you all the npm modules in your project that are out of date.

npm outdate -g

-This will show you all of the projects that are out of date in the global environment.

npm update

-This will update all of the npm modules in your project.

npm update package name

-This will update a specific package in your project.

npm update package name -g

-This will update a specific global package.

Uninstall

npm unistall package-name —save

-This will remove an npm package from the projects node_modules and package.json

npm uninstall package-name -g

-This will remove an npm package globally. 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment