npm全局安装&局部安装&指令列表

1 查看npm指令帮助

npm指令帮助

C:\Users\10321>npm -h
npm <command>

Usage:

npm install        install all the dependencies in your project
npm install <foo>  add the <foo> dependency to your project
npm test           run this project's tests
npm run <foo>      run the script named <foo>
npm <command> -h   quick help on <command>
npm -l             display usage info for all commands
npm help <term>    search for help on <term> (in a browser)
npm help npm       more involved overview (in a browser)

All commands:

    access, adduser, audit, bin, bugs, cache, ci, completion,
    config, dedupe, deprecate, diff, dist-tag, docs, doctor,
    edit, exec, explain, explore, find-dupes, fund, get, help,
    hook, init, install, install-ci-test, install-test, link,
    ll, login, logout, ls, org, outdated, owner, pack, ping,
    pkg, prefix, profile, prune, publish, rebuild, repo,
    restart, root, run-script, search, set, set-script,
    shrinkwrap, star, stars, start, stop, team, test, token,
    uninstall, unpublish, unstar, update, version, view, whoami

Specify configs in the ini-formatted file:
    C:\Users\10321\.npmrc
or on the command line via: npm <command> --key=value

More configuration info: npm help config
Configuration fields: npm help 7 config

npm@8.5.0 D:\Envs\nvm\nvm\v16.14.2\node_modules\npm

cnpm指令帮助

C:\Users\10321>cnpm -h

  Usage: cnpm [options]

  Options:

    -h, --help                       output usage information
    -v, --version                    show full versions
    -r, --registry [registry]        registry url, default is https://registry.npmmirror.com
    -w, --registryweb [registryweb]  web url, default is https://npmmirror.com
    --disturl [disturl]              dist url for node-gyp, default is https://npmmirror.com/mirrors/node
    -c, --cache [cache]              cache folder, default is C:\Users\10321\.cnpm
    -u, --userconfig [userconfig]    userconfig file, default is C:\Users\10321\.cnpmrc
    -y, --yes                        yes all confirm
    --ignore-custom-config           ignore custom .cnpmrc
    --proxy [proxy]                  set a http proxy, no default

Usage: cnpm [option] <command>
Help: http://cnpmjs.org/help/cnpm

  Extend command
    web                            open cnpm web (ex.: cnpm web)
    check [ingoreupdate]           check project dependencies, add ignoreupdate will not check modules' latest version(ex.: cnpm check, cnpm check -i)
    doc [moduleName]               open document page (ex.: cnpm doc egg)
    sync [moduleName]              sync module from source npm (ex.: cnpm sync egg)
    user [username]                open user profile page (ex.: cnpm user fengmk2)

  npm command use --registry=https://registry.npmmirror.com
    where <command> is one of:
    add-user, adduser, apihelp, author, bin, bugs, c, cache,
    completion, config, ddp, dedupe, deprecate, docs, edit,
    explore, faq, find, find-dupes, get, help, help-search,
    home, i, info, init, install, isntall, la, link, list, ll,
    ln, login, ls, outdated, owner, pack, prefix, prune,
    publish, r, rb, rebuild, remove, restart, rm, root,
    run-script, s, se, search, set, show, shrinkwrap, star,
    start, stop, submodule, tag, test, tst, un, uninstall,
    unlink, unpublish, unstar, up, update, v, version, view,
    whoami
      npm <cmd> -h     quick help on <cmd>
      npm -l           display full usage info
      npm faq          commonly asked questions
      npm help <term>  search for help on <term>
      npm help npm     involved overview

      Specify configs in the ini-formatted file:
          C:\Users\10321\.cnpmrc
      or on the command line via: npm <command> --key value
      Config info can be viewed via: npm help config

2 常用指令

全局安装,node包会被下载到全局目录下

npm install xxx -g 

本地安装,安装在当前文件夹下面

npm install xxx 

运行依赖

npm install xxx -g --save  

安装完成之后保存在package.json 的dependencies中

开发依赖

npm install xxx -g --save-dev

安装之后保存在package.json的devdependencies中

删除全局模块

npm uninstall -g <package>

删除局部模块

npm uninstall <package>

删除全局模块,同时清除package.json

npm uninstall 模块:删除模块,但不删除模块留在package.json中的对应信息
npm uninstall 模块 --save 删除模块,同时删除模块留在package.json中dependencies下的对应信息
npm uninstall 模块 --save-dev 删除模块,同时删除模块留在package.json中devDependencies下的对应信息

3 发布自己的node包

第一次发布

在终端输入npm adduser,提示输入账号,密码和邮箱,然后将提示创建成功

不是第一次发布

在终端输入npm login,然后输入你创建的账号和密码,和邮箱,登陆
【注意】npm adduser成功的时候默认你已经登陆了,所以不需要再接着npm login.

在这里插入图片描述

在这里插入图片描述

撤销发布的包

在这里插入图片描述

更新发布的包

在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kobe_OKOK_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值