npm install/i -g/-S/-D命令总结

本文详细介绍了npm install命令的各种用法,包括本地安装、全局安装、指定版本安装等,并解释了如何使用简写形式及各种选项参数,如--save、--save-dev等。

cmd查看npm install的帮助:

npm install -h

npm install (with no args, in package dir)
npm install [<@scope>/]<pkg>
npm install [<@scope>/]<pkg>@<tag>
npm install [<@scope>/]<pkg>@<version>
npm install [<@scope>/]<pkg>@<version range>
npm install <folder>
npm install <tarball file>
npm install <tarball url>
npm install <git:// url>
npm install <github username>/<github project>

aliases: i, isntall, add
common options: [--save-prod|--save-dev|--save-optional] [--save-exact] [--no-save]
命令&参数的完整写法简写含义
npm install xxxnpm i xxx本地安装xxx包
–global-g全局安装,安装后可直接使用相应包里面提供的命令
–save-S本地安装,安装版本写入package.jsondependencies
–save-dev-D本地安装,安装版本写入package.jsondevDependencies
[gitlab-runner@c ~]$ npm install gitbook-cli -g npm WARN deprecated q@1.5.0: You or someone you depend on is using Q, the JavaScript Promise library that gave JavaScript developers strong feelings about promises. They can almost certainly migrate to the native JavaScript promise now. Thank you literally everyone for joining me in this bet against the odds. Be excellent to each other. npm WARN deprecated npm WARN deprecated (For a CapTP with native promises, see @endo/eventual-send and @endo/captp) [..................] - fetchMetadata: WARN deprecated q@1.5.0: You or someone you depend on is using Q, the JavaScript Promise library that gave JavaScript developers strong feelings about promises. They can almost certainly migrate to the native JavaScri [..................] | fetchMetadata: WARN deprecated q@1.5.0: You or someone you depend on is using Q, the JavaScript Promise library that gave JavaScript developers strong feelings about promises. They can almost certainly migrate to the native JavaScri [..................] \ fetchMetadata: WARN deprecated q@1.5.0: You or someone you depend on is using Q, the JavaScript Promise library that gave JavaScript developers strong feelings about promises. They can almost certainly migrate to the native JavaScri npm WARN checkPermissions Missing write access to /usr/local/node/lib/node_modules/gitbook-cli/node_modules/npmi/node_modules/npm/node_modules/ansistyles npm WARN checkPermissions Missing write access to /usr/local/node/lib/node_modules/gitbook-cli/node_modules/npmi/node_modules/npm/node_modules/path-is-inside npm WARN checkPermissions Missing write access to /usr/local/node/lib/node_modules/gitbook-cli npm WARN checkPermissions Missing write access to /usr/local/node/lib/node_modules/gitbook-cli/node_modules/npmi/node_modules/npm/node_modules npm WARN checkPermissions Missing write access to /usr/local/node/lib/node_modules npm ERR! code EACCES npm ERR! syscall access npm ERR! path /usr/local/node/lib/node_modules/gitbook-cli/node_modules/npmi/node_modules/npm/node_modules/ansistyles npm ERR! errno -13 npm ERR! Error: EACCES: permission denied, access '/usr/local/node/lib/node_modules/gitbook-cli/node_modules/npmi/node_modules/npm/node_modules/ansistyles' npm ERR! [Error: EACCES: permission denied, access '/usr/local/node/lib/node_modules/gitbook-cli/node_modules/npmi/node_modules/npm/node_modules/ansistyles'] { npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'access', npm ERR! path: '/usr/local/node/lib/node_modules/gitbook-cli/node_modules/npmi/node_modules/npm/node_modules/ansistyles' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It is likely you do not have the permissions to access this file as the current user npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm ERR! A complete log of this run can be found in: npm ERR! /home/gitlab-runner/.npm/_logs/2025-08-14T09_56_46_078Z-debug.log
08-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值