我正在尝试构建 pwa
。所以先运行 ng add @angular/pwa
效果很好。
但是 ionic build --prod
失败了
$ app# ionic build --prod --verbose
ionic:lib Terminal info: { ci: false, shell: '/bin/bash', tty: true, windows: false } +0ms
ionic:lib CLI global options: { _: [ 'build' ], help: null, h: null, verbose: true, quiet: null, interactive: true, color: true, confirm: null, json: null, prod: true, project: null, '--': [] } +6ms
ionic:lib:project Project type from config: @ionic/angular (angular) +0ms
ionic:lib:project Project details: { context: 'app', type: 'angular', errors: [], configPath: '/doctor-app/ionic.config.json' } +1ms
ionic Context: { binPath: '/usr/local/lib/node_modules/@ionic/cli/bin/ionic', libPath: '/usr/local/lib/node_modules/@ionic/cli', execPath: '/doctor-app', version: '6.12.3' } +0ms
ionic:lib:build build options: { '--': [],
ionic:lib:build engine: 'browser',
ionic:lib:build platform: undefined,
ionic:lib:build project: 'app',
ionic:lib:build verbose: true,
ionic:lib:build configuration: 'production',
ionic:lib:build sourcemaps: undefined,
ionic:lib:build cordovaAssets: true,
ionic:lib:build watch: undefined,
ionic:lib:build type: 'angular' } +0ms
ionic:lib:telemetry Sending telemetry for command: 'ionic build' [ '--prod', '--verbose', '--interactive', '--color' ] +0ms
ionic:lib:hooks Looking for ionic:build:before npm script. +0ms
ionic:lib:build Looking for ionic:build npm script. +26ms
> ng run app:build:production --verbose
ng:analytics getGlobalAnalytics +0ms
ng:analytics Client Analytics config found: "ea8c9b1d-f1d3-43d8-ad1c-7d1e8b3f92ea" +7ms
ng:analytics client id: "ea8c9b1d-f1d3-43d8-ad1c-7d1e8b3f92ea" +1ms
ng:analytics getWorkspaceAnalytics +10ms
ng:analytics Workspace Analytics config found: false +0ms
ng:analytics Analytics disabled. Ignoring all analytics. +0ms
ng:analytics getSharedAnalytics +1ms
This version of CLI is only compatible with Angular versions 0.0.0 || ^11.0.0-beta || >=11.0.0 <12.0.0,
but Angular version 9.1.13 was found instead.
Please visit the link below to find instructions on how to update Angular.
https://update.angular.io/
[ERROR] An error occurred while running subprocess ng.
ng run app:build:production --verbose exited with exit code 3.
Re-running this command with the --verbose flag may provide more information.
ionic:utils-process onBeforeExit handler: 'process.exit' received +0ms
ionic:utils-process onBeforeExit handler: running 1 functions +0ms
ionic:utils-process processExit: exiting (exit code: 3) +14ms
我在这里缺少什么?
包裹信息
app# ionic info
Ionic:
Ionic CLI : 6.12.3 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 5.2.3
@angular-devkit/build-angular : 0.901.11
@angular-devkit/schematics : 9.1.11
@angular/cli : 11.0.5
@ionic/angular-toolkit : 2.2.0
Cordova:
Cordova CLI : not installed
Cordova Platforms : not available
Cordova Plugins : not available
Utility:
cordova-res : not installed
native-run : not installed
System:
NodeJS : v10.19.0 (/usr/bin/node)
npm : 6.14.4
OS : Linux 4.19
$ app# node -v
v10.19.0
$ app# npm -v
6.14.4
$ app# ng version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 11.0.5
Node: 10.19.0
OS: linux x64
Angular: 9.1.13
... common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker
Ivy Workspace: Yes
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.901.11
@angular-devkit/build-angular 0.901.11
@angular-devkit/core 9.1.11
@angular-devkit/schematics 9.1.11
@angular/cli 11.0.5
@schematics/angular 9.1.11
@schematics/update 0.1100.5
rxjs 6.5.5
typescript 3.8.3
答案 0 :(得分:0)
看起来您必须安装一些软件包才能使其正常工作。
sudo npm install -g ionic cordova native-run cordova-res
cordova platform rm android
cordova platform add android
ionic cordova run android --prod
答案 1 :(得分:0)
卸载当前的angular cli:
npm uninstall @angular/cli
在其版本 10.2.1 中安装 angular cli:
npm install @angular/cli@10.2.1 --save-dev