首页 > 解决方案 > 为什么 npm 包会将 node_modules 文件夹安装到自身中?

问题描述

为什么 npm 包会将 node_modules 文件夹安装到自身中? npm 文件夹

包.json

{
  "name": "",
  "description": "package",
  "main": "src/public-api.ts",
  "files": [
    "src/"
  ],
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "tsc",
    "format": "prettier --write \"src/**/*.ts\"",
    "lint": "tslint -p tsconfig.json"
  },
  "repository": {
    "type": "git",
    "url": ""
  },
  "author": "",
  "license": "MIT",
  "bugs": {
    "url": ""
  },
  "homepage": "",
  "preversion": "npm run lint",
  "prepublishOnly": "npm run lint",
  "version": "1.0.0",
  "postversion": "git push && git push --tags",
  "prepare": "npm run build",
  
  "dependencies": {
    "@angular/common": "^7.1.0",
    "@angular/core": "^7.1.0",
    "@angular/forms": "^7.1.0",
    "@angular/router": "^7.1.0",
    "rxjs": "^6.3.3",
    "moment": "^2.24.0"
  }
}

如果您在包本身中删除 node_modules,那么一切正常。

标签: npmpackage.json

解决方案


推荐阅读