npm 的主要功能

  1. 下载别人编写的第三方包到本地使用
  2. 下载并安装别人编写的 CLI 到本地使用
  3. 将自己编写的包或命令行程序发布到 npm上

package.json优化

  1. 上线精简 devpendenciespeer & Devpendencies
  2. 把上线依赖的,移动到开发依赖
  1. {
  2. "name": "webpack-demo",
  3. "version": "1.0.0",
  4. "private": true, // 私有仓库
  5. "main": "src/index.js", // 向外暴露的 js入口文件
  6. "scripts": {
  7. "start": "npx webpack",
  8. "build": "echo \"Error: no test specified\" && exit 1",
  9. "test": "echo \"Error: no test specified\" && exit 1"
  10. },
  11. "dependencies": {},
  12. "devDependencies": {
  13. "cross-env": "^7.0.3",
  14. "webpack": "^5.73.0",
  15. "webpack-cli": "^4.10.0"
  16. },
  17. "description": "项目描述",
  18. "keywords": ["项目关键词"],
  19. "author": "",
  20. "license": "MIT"
  21. }