关于npm

npm

安装
     npm install (with no args, in package dir)
     npm install [<@scope>/]<name>
     npm install [<@scope>/]<name>@<tag>
     npm install [<@scope>/]<name>@<version>
     npm install [<@scope>/]<name>@<version range>
     npm install <alias>@npm:<name>
     npm install <git-host>:<git-user>/<repo-name>
     npm install <git repo url>
     npm install <tarball file>
     npm install <tarball url>
     npm install <folder>

     别名: npm i, npm add
     common options: [-P|--save-prod|-D|--save-dev|-O|--save-optional|--save-peer] [-E|--save-exact] [-B|--save-bundle] [--no-save] [--dry-run]
卸载
     npm uninstall [<@scope>/]<pkg>[@<version>]... [-S|--save|--no-save]

     aliases: remove, rm, r, un, unlink
更新
  •    npm update [-g] [<pkg>...]
    
       aliases: up, upgrade
    
  • npm outdated [[<@scope>/] …]
    此命令会列出所有已经过时的包,可以及时进行包的更新

查看
     npm ls [[<@scope>/]<pkg> ...]

     aliases: list, la, ll
init
  •    npm init [--yes|-y|--scope]
       npm init <@scope> (same as `npm exec <@scope>/create`)
       npm init [<@scope>/]<name> (same as `npm exec [<@scope>/]create-<name>`)
       npm init [-w <dir>] [args...]
    
  • create a package.json file
help
     npm help <term> [<terms..>]

   Note: This command is unaware of workspaces.
root
     npm root [-g]
config
     npm config set <key>=<value> [<key>=<value> ...]
     npm config get [<key> [<key> ...]]
     npm config delete <key> [<key> ...]
     npm config list [--json]
     npm config edit
     npm set <key>=<value> [<key>=<value> ...]
     npm get [<key> [<key> ...]]

     alias: c

   Note: This command is unaware of workspaces.
  • 代理npm config set proxy=http://xxx.com:8080
  • 镜像npm config set registry=“http://r.cnpmjs.org”
  • 安装淘宝镜像 npm install -g cnpm --registry=https://registry.npm.taobao.org
cache
     npm cache add <tarball file>...
     npm cache add <folder>...
     npm cache add <tarball url>...
     npm cache add <name>@<version>...

     npm cache clean
     aliases: npm cache clear, npm cache rm

     npm cache verify

   Note: This command is unaware of workspaces.
start
  •      npm start [-- <args>]
    
  • Description
    This runs a predefined command specified in the “start” property of
    a package’s “scripts” object.
    If the “scripts” object does not define a “start” property, npm will run
    node server.js.
    Note that this is different from the default node behavior of runnin the
    file specified in a package’s “main” attribute when evoking with node .
stop
  •      npm stop [-- <args>]
    
  • This runs a predefined command specified in the “stop” property of a package’s “scripts” object.
    Unlike with npm help start, there is no default script that will run if the “stop” property is not defined.
    • Example
      {
      “scripts”: {
      “stop”: “node bar.js”
      }
      }
restart
     npm restart [-- <args>]
   This  restarts  a  project.   It  is  equivalent to running npm run-script
   restart.

   If the current project has a "restart" script specified  in  package.json,
   then the following scripts will be run:
   
   1. prerestart
   2. restart
   3. postrestart

   If  it  does  not have a "restart" script specified, but it does have stop
   and/or start scripts, then the following scripts will be run:
   
   1. prerestart
   2. prestop
   3. stop
   4. poststop
   5. prestart
   6. start
   7. poststart
   8. postrestart
test
     npm test [-- <args>]

     aliases: t, tst
  • This runs a predefined command specified in the “test” property of a pack‐
    age’s “scripts” object.
  •    {
         "scripts": {
           "test": "node test.js"
         }
       }
    
version
     npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease [--preid=<prerelease-id>] | from-git]

     'npm [-v | --version]' to print npm version
     'npm view <pkg> version' to view a package's published version
     'npm ls' to inspect current package/dependency versions
view
adduser

package.json

链接

其它

npm-check
  • -y/u(有否交互)-g(全局)
nrm
  • 查看下载镜像源nrm ls
  • 切换镜像源nrm use []
n

n stable

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值