Be better to use NPM

Lewis77發表於2018-12-27

Generate package.json

$ npm init -y
$ npm init --yes

Install package

$ npm i
$ npm i gulp-pug
$ npm i gulp-debug
$ npm i gulp-sass
$ npm i gulp-pug gulp-debug gulp-sass
$ npm i gulp{-debug,-sass,-pug}

$ npm i https://github.com/sindresorhus/gulp-debug

Install with envirment

$ npm i gulp --save-prod
// less
$ npm i gulp -P

$ npm i gulp --save-dev
// less
$ npm i gulp -D

Get package info

$ npm view vue
$ npm v vue
$ npm v vue verison
$ npm v vue verisons

Search package

$ npm search gulp debug
// less
$ npm s gulp debug

Uninstall package

$ npm uninstall vue
$ npm rm vue
// Save package dependency
$ npm rm vue --no-save

Run test

$ npm run test
$ npm test
$ npm t

List env

$ npm run env | grep npm_

Repeatable build

$npm config set save-exact true

$ npm install --save-exact aDependency
# Simple
$ npm i -E aDependency

Install package

require package-lock.json or npm-shrinkwrap.json

$ npm ci

Safety

To find the unsafety package

$ npm audit fix

Update package

  • case 1
     $ npx updtr
  • case 2
     $ npx npm-check -u
本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章