npm i

一、-S,-D,-g的解释

npm install module_name -S    即    npm install module_name --save    写入dependencies

npm install module_name -D    即    npm install module_name --save-dev 写入devDependencies

npm install module_name -g 全局安装(命令行使用)

npm install module_name 本地安装(将安装包放在 ./node_modules 下)

二、i是install的缩写,

npm install module_name -S  <=> npm i module_name -S

三、dependencies与devDependencies的区别

devDependencies 里面的插件只用于开发环境,不用于生产环境

dependencies 是需要发布到生产环境的

比如说:

你开发一个前端项目,在项目中你需要使用gulp构建你的开发和本地运行环境,这时你就要放到devDependencies里。gulp是你用来压缩代码,打包等需要的工具,程序实际运行的时候并不需要,所以放到dev里就ok了。

你写程序要用element-ui,生产环境运行项目时肯定要用到element-ui,这时element-ui就应该安装到dependencies中去。

### NPM Install vs NPM I Differences in Node.js Package Management In the context of managing dependencies within a Node.js project, `npm install` and its shorthand form `npm i` serve identical purposes but offer different user experiences through syntax brevity. The command `$ cd build-site-2$ npm install npm-run-all --save-dev` demonstrates installing a development dependency using the full command name[^1]. This operation adds `npm-run-all` as a devDependency to the `package.json`. Using `npm i`, developers can achieve exactly what `npm install` does but with less typing. For instance: ```bash npm i npm-run-all --save-dev ``` Both commands will update or add entries under `"devDependencies"` in `package.json`. The choice between them often comes down to personal preference regarding verbosity versus conciseness. When considering compatibility concerns related to module imports such as those mentioned for handling ES modules alongside CommonJS modules[^2], these installation methods do not affect how one writes code to support multiple environments; they only differ syntactically during package addition. For projects where data storage mechanisms are being considered—such as choosing whether to store information temporarily in memory rather than persistently in databases—it's worth noting that this decision impacts application behavior outside of dependency management practices[^3]. --related questions-- 1. What other flags besides '--save-dev' exist when running 'npm install'? 2. How does adding packages impact performance in non-production settings compared to production ones? 3. Can you explain more about dual CommonJS/ES module packages and their importance in Node.js applications? 4. In which scenarios would someone prefer verbose commands over shorter alternatives like 'npm i'?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值