【问题标题】:How to install dependency scripts while installing an npm module [duplicate]如何在安装 npm 模块时安装依赖脚本 [重复]
【发布时间】:2018-04-28 16:50:18
【问题描述】:

我最近向 npm 发布了一个 angular 2 库。我在库 package.json 文件中列出了所有依赖脚本。当我运行npm install my-library 时,所有依赖脚本都没有安装。所以,我的问题是如何在安装库时安装依赖脚本。

【问题讨论】:

  • @Héctor 只是安装一个模块并将包版本写入 package.json。

标签: javascript angular npm npm-install npm-scripts


【解决方案1】:

(这个答案对npm5+有效)在package.json你可以指定3种依赖:

  • peerDependencies - 在任何情况下都不会自动下载它们(“好有”)
  • devDependencies - 在项目本身中运行 npm install 时下载,此处列出的包仅用于开发目的
  • dependencies - 在每个 npm install 上下载(在将您的包添加到某人的项目时,“必须拥有”)

例子:

{
  "peerDependencies": {
    "@angular/core": ">=2.3.0",
  },
  "devDependencies": {
    "@angular/compiler": "~4.0.0",
    "@angular/compiler-cli": "~4.0.0",
    "@angular/core": "~4.0.0",
    "@angular/platform-server": "~4.0.0",
    "@types/node": "^7.0.39",
    "core-js": "^2.4.1",
    "es6-shim": "^0.35.3",
    "rimraf": "^2.5.4",
    "rxjs": "^5.4.2",
    "tslint": "^4.5.0",
    "typescript": "^2.6.1",
    "zone.js": "^0.8.16"
  },
  "dependencies": {
    "ngx-store": "^1.2.2"
  }
}

【讨论】:

    猜你喜欢
    • 2013-08-26
    • 2018-03-29
    • 2016-03-14
    • 2014-02-17
    • 1970-01-01
    • 2019-07-01
    • 2017-04-08
    • 2020-07-04
    • 1970-01-01
    相关资源
    最近更新 更多