[英]An unhandled exception occurred: Configuration 'dev' is not set in the workspace
I started to publish my Angular app.我开始发布我的 Angular 应用程序。 But I can't fix this error.
但我无法修复这个错误。 I deployed in Azure.
我部署在 Azure 中。 Add this looking easy.
添加这个看起来很容易。 I think that the problem is in
angular.json
.我认为问题出在
angular.json
。 Firstly I tried to update every dependency in package.json
首先,我尝试更新
package.json
每个依赖项
Where is the wrong in this config file?这个配置文件哪里错了?
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"ODZ.Web": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"progress": false,
"extractCss": false,
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/assets"
],
"styles": [
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"node_modules/@fortawesome/fontawesome-free/scss/fontawesome.scss",
"node_modules/@fortawesome/fontawesome-free/scss/solid.scss",
"node_modules/@fortawesome/fontawesome-free/scss/regular.scss",
"node_modules/@fortawesome/fontawesome-free/scss/brands.scss",
"node_modules/angular-bootstrap-md/assets/scss/bootstrap/bootstrap.scss",
"node_modules/angular-bootstrap-md/assets/scss/mdb.scss",
"node_modules/animate.css/animate.css",
"src/styles.css"
],
"scripts": [
"node_modules/chart.js/dist/Chart.js",
"node_modules/hammerjs/hammer.min.js"
]
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "ODZ.Web:build"
},
"configurations": {
"production": {
"browserTarget": "ODZ.Web:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "ODZ.Web:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.css"
],
"scripts": [],
"assets": [
"src/assets"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
},
"server": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "dist-server",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.server.json"
}
}
}
},
"ODZ.Web-e2e": {
"root": "e2e/",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "ODZ.Web:serve"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
},
"configurations": {
"production": {
"devServerTarget": "ODZ.Web:serve:production"
}
}
}
}
}
},
"defaultProject": "ODZ.Web"
}
I tried to fix this, but when I execute npm build --prod
... I changed every dependency in my project, but didn't help.我试图解决这个问题,但是当我执行
npm build --prod
......我改变了我项目中的每个依赖项,但没有帮助。 If someone is fixing this error.如果有人正在修复此错误。 Bro, pleas help!
兄弟,求帮助! Thanks!
谢谢!
I had a similar error when I ran the build command as below:当我运行构建命令时,我遇到了类似的错误,如下所示:
ng build --configuration=DEV --crossOrigin=anonymous
In Jenkins:在詹金斯:
An unhandled exception occurred: Configuration 'DEV' is not set in the workspace.
In log file:在日志文件中:
Log filename: /tmp/ng-W1hy24/angular-errors.log
[error] Error: Configuration 'DEV' is not set in the workspace.
I believe below are two reasons causing the issue in the angular.json file.我相信以下是导致 angular.json 文件中出现问题的两个原因。
Check if you are missing the configuration for DEV, add something similar below.检查您是否缺少 DEV 的配置,在下面添加类似的内容。
code sample:代码示例:
"DEV": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.dev.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "4mb",
"maximumError": "6mb"
}
],
"serviceWorker": true,
"ngswConfigPath": "ngsw-config.json"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.