关于前端:devDependenciesdependencies与save-dev

4次阅读

共计 821 个字符,预计需要花费 3 分钟才能阅读完成。

npm install moduleName

1. 装置模块到我的项目 node_modules 目录下。2. 不会将模块依赖写入 devDependencies 或 dependencies 节点。3. 运行 npm install 初始化我的项目时不会下载模块。

npm install -g moduleName

1. 装置模块到全局,不会在我的项目 node_modules 目录中保留模块包。2. 不会将模块依赖写入 devDependencies 或 dependencies 节点。3. 运行 npm install 初始化我的项目时不会下载模块。

npm install -save moduleName

1. 装置模块到我的项目 node_modules 目录下。2. 会将模块依赖写入 dependencies 节点。3. 运行 npm install 初始化我的项目时,会将模块下载到我的项目目录下。4. 运行 npm install --production 或者注明 NODE_ENV 变量值为 production 时,会主动下载模块到 node_modules 目录中。

npm install -save-dev moduleName 命令

1. 装置模块到我的项目 node_modules 目录下。2. 会将模块依赖写入 devDependencies 节点。3. 运行 npm install 初始化我的项目时,会将模块下载到我的项目目录下。4. 运行 npm install --production 或者注明 NODE_ENV 变量值为 production 时,不会主动下载模块到 node_modules 目录中。

npm 5.x+ 版本默认增加 –save
将运行时的依赖装置到 dependencies,将开发时的依赖装置到 devDependencies
公布组件的 npm 包:须要辨别两者,因为公布的 npm 包他人在用的时候要通过 pack.json 去下载安装组件依赖的包
我的项目开发关系不大:我的项目在浏览器运行,无谓开发依赖还是生产依赖,只是良好的习惯代码最终都会打包到一起

正文完
 0