构建Angular5库时出现BrowserslistError

时间:2018-08-15 06:19:24

标签: angular npm angular5

因此,我正在构建Angular库,并且在设置自动化构建环境时遇到了一些麻烦。这是我的文件夹设置:

my-app/
..my-lib/
....package.json
..package.json

my-lib下运行npm install之前,我需要先构建my-app。原因是,我不能只在npm install目录中执行my-app,因为它引用的是file:my-lib/dist,直到我构建my-lib才存在。我可以在签到过程中删除此行,并始终在测试时将其添加到本地,但我希望保留其中以使其更加简化。

在主应用程序的package.json中,我有:

"dependencies": {
    "@angular/animations": "^5.2.0",
    "@angular/common": "^5.2.0",
    "@angular/compiler": "^5.2.0",
    "@angular/core": "^5.2.0",
    "@angular/forms": "^5.2.0",
    "@angular/http": "^5.2.0",
    "@angular/platform-browser": "^5.2.0",
    "@angular/platform-browser-dynamic": "^5.2.0",
    "@angular/router": "^5.2.0",
    "my-lib": "file:my-lib/dist",
    "core-js": "^2.4.1",
    "rxjs": "^5.5.6",
    "zone.js": "^0.8.19"
},
"devDependencies": {
    "@angular-devkit/core": "^0.3.2",
    "@angular/cli": "~1.7.4",
    "@angular/compiler-cli": "^5.2.0",
    "@angular/language-service": "^5.2.0",
    "@types/jasmine": "^2.8.8",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.4.3",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "ng-packagr": "^3.0.6",
    "protractor": "~5.1.2",
    "ts-node": "~4.1.0",
    "tsickle": "^0.32.1",
    "tslint": "~5.9.1",
    "typescript": "^2.6.2",
    "webpack": "^3.11.0"
}

在我的lib的{​​{1}}中,我有:

package.json

我要对构建系统执行的操作是:

  1. 安装"peerDependencies": { "@angular/animations": ">=5.0.0", "@angular/core": ">=5.0.0", "@angular/common": ">=5.0.0", "@angular/compiler": ">=5.0.0", "@angular/forms": ">=5.0.0", "@angular/http": ">=5.0.0", "@angular/platform-browser": ">=5.0.0", "@angular/router": ">=5.0.0", "rxjs": "^5.5.6" }, "dependencies": { "<externalDependency>": "^1.0.0", }, 的开发依赖项
  2. 安装对等依赖项my-app
  3. my-lib构建ng-packagr
  4. my-lib for npm install

最初,我有以下步骤:

  • my-app
  • cd my-app //安装devDependencies
  • npm install --only=dev
  • npm install <manually put all my-lib peerDependencies>
  • cd my-lib //将外部依赖项安装到my-app节点模块中
  • npm install --prefix ../
  • cd ..

但是,构建在这里失败,并显示错误:

ng-packagr -p my-lib/package.json

我以前在本地遇到过此问题,但是我能够删除Unknown browser query `basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")` BrowserslistError: Unknown browser query `basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")` 文件来使其正常工作。但是,在构建机器上,我不确定该文件在哪里。我需要做些什么来使它成功构建吗?

0 个答案:

没有答案