我正在将Angular应用程序部署到Netlify。这个应用程式已经部署了许多次,并且没有任何问题。最近,在添加新功能的同时,我将应用程序从Angular 5升级到了7,并升级了许多依赖项。现在,构建失败了,几乎没有任何信息。
在Netlify上,我使用的构建命令为:
ng build --target=development --environment=staging
for dev and
ng build --target=production --environment=prod
for prod。
Netlify上的日志为:
3:54:11 PM: Fetching cached dependencies
3:54:11 PM: Starting to download cache of 99.4MB
3:54:12 PM: Finished downloading cache in 773.818516ms
3:54:12 PM: Starting to extract cache
3:54:17 PM: Finished extracting cache in 4.66127562s
3:54:17 PM: Finished fetching cache in 5.479273794s
3:54:17 PM: Starting to prepare the repo for build
3:54:17 PM: Preparing Git Reference pull/102/head
3:54:18 PM: Starting build script
3:54:18 PM: Installing dependencies
3:54:19 PM: Started restoring cached node version
3:54:21 PM: Finished restoring cached node version
3:54:21 PM: v8.15.1 is already installed.
3:54:22 PM: Now using node v8.15.1 (npm v6.4.1)
3:54:23 PM: Attempting ruby version 2.3.6, read from environment
3:54:24 PM: Using ruby version 2.3.6
3:54:24 PM: Using PHP version 5.6
3:54:24 PM: Started restoring cached node modules
3:54:24 PM: Finished restoring cached node modules
3:54:24 PM: Installing NPM modules using NPM version 6.4.1
3:55:17 PM: > node-sass@4.11.0 install /opt/build/repo/node_modules/node-sass
3:55:17 PM: > node scripts/install.js
3:55:17 PM: Downloading binary from https://github.com/sass/node-sass/releases/download/v4.11.0/linux-x64-57_binding.node
3:55:18 PM: Download complete
3:55:18 PM: Binary saved to /opt/build/repo/node_modules/node-sass/vendor/linux-x64-57/binding.node
3:55:18 PM: Caching binary to /opt/buildhome/.npm/node-sass/4.11.0/linux-x64-57_binding.node
3:55:19 PM: > node-sass@4.11.0 postinstall /opt/build/repo/node_modules/node-sass
3:55:19 PM: > node scripts/build.js
3:55:19 PM: Binary found at /opt/build/repo/node_modules/node-sass/vendor/linux-x64-57/binding.node
3:55:19 PM: Testing binary
3:55:19 PM: Binary is fine
3:55:22 PM: npm WARN
3:55:22 PM: optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/webpack-dev-server/node_modules/fsevents):
3:55:22 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
3:55:22 PM: npm WARN optional
3:55:22 PM: SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):
3:55:22 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
3:55:22 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/@angular/compiler-cli/node_modules/fsevents):
3:55:22 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
3:55:22 PM: npm
3:55:22 PM: WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/@angular-devkit/core/node_modules/fsevents):
3:55:22 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
3:55:22 PM: added 561 packages from 247 contributors, removed 635 packages, updated 323 packages and audited 36240 packages in 57.022s
3:55:22 PM: found 0 vulnerabilities
3:55:23 PM: NPM modules installed
3:55:23 PM: Started restoring cached go cache
3:55:23 PM: Finished restoring cached go cache
3:55:23 PM: unset GOOS;
3:55:23 PM: unset GOARCH;
3:55:23 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.10.linux.amd64';
3:55:23 PM: export PATH="/opt/buildhome/.gimme/versions/go1.10.linux.amd64/bin:${PATH}";
3:55:23 PM: go version >&2;
3:55:23 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.10.linux.amd64.env';
3:55:23 PM: go version go1.10 linux/amd64
3:55:23 PM: Installing missing commands
3:55:23 PM: Verify run directory
3:55:23 PM: Executing user command: ng build --target=development --environment=staging
3:55:25 PM: Unknown option: '--target'
3:55:25 PM: Unknown option: '--environment'
3:55:25 PM: Caching artifacts
3:55:25 PM: Started saving node modules
3:55:25 PM: Finished saving node modules
3:55:25 PM: Started saving pip cache
3:55:25 PM: Finished saving pip cache
3:55:25 PM: Started saving emacs cask dependencies
3:55:25 PM: Finished saving emacs cask dependencies
3:55:25 PM: Started saving maven dependencies
3:55:25 PM: Finished saving maven dependencies
3:55:25 PM: Started saving boot dependencies
3:55:25 PM: Finished saving boot dependencies
3:55:25 PM: Started saving go dependencies
3:55:25 PM: Finished saving go dependencies
3:55:25 PM: Error running command: Build script returned non-zero exit code: 1
3:55:25 PM: Failing build: Failed to build site
3:55:29 PM: Finished processing build request in 1m20.618386048s
3:55:30 PM: Shutting down logging, 0 messages pending
我注意到--target=
和--environment=
未被处理。在过去成功的部署日志中,这些选项很好用。所以我假设部署问题与此有关。
有人可以为此提供一些指导吗?
谢谢。
答案 0 :(得分:4)
检查docs的ng build命令以获取最新的Angular CLI命令。
缺少这两个选项:
3:55:25 PM: Unknown option: '--target'
3:55:25 PM: Unknown option: '--environment'
对于--target
,您可以指定--prod=true
以及--environment
--configuration=production
(来自angular.json文件)
答案 1 :(得分:2)
我相信您可以改用以下参数
对于开发人员:
--configuration=development
--prod=false
产品:
--configuration=production
--prod=true
您还可以阅读有关here
可以使用的所有参数的信息。