Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mkdir new-project && cd new-project
- # create package.json file
- npm init # use --yes to skip set-up questions
- #INSTALLING NEW PACKAGES. Note: Creates node_modules folder to hold source code for packages.
- # See package.json file after installing new packages.
- # for non-dev dependencies
- npm install package
- # for dev dependencies
- npm install package --save-dev
- # specify version
- npm install package@x.x.x
- # View dependencies tree (installed packages, plus their dependencies). Includes version metadata
- npm list
- # View only project dependencies
- npm list --depth=0
- # Check if newer package versions available
- npm outdated
- # update packages. Note: npm checks versioning in package.json to make sure updates don't break your app.
- # for example, if 6.0.0 was available for mongoose and in package.json mongoose: "dependencies": {
- # "mongoose": "^5.2.8",
- # "underscore": "^1.9.1"
- # then npm would update to latest major 5 version
- npm update
- # update to latest version
- # first install npm-check-updates globally
- npm i -g npm-check-updates
- # run it
- npm-check-updates
- # or
- ncu
- # then
- npm install
- # uninstalling packages
- npm uninstall package
- # or
- npm un package
- # publish package on npm (requires sign-up). Simple
- # open terminal from within project folder
- npm publish
- # updating a published package
- # terminal in project folder
- # choose one from major, minor, or patch. if adding functionality, minor, if bug fix, patch. if change could break, then major
- npm version major/minor/patch
Add Comment
Please, Sign In to add comment