Reputation: 244
I am trying to debug Angular app with Angular DevTools for Chrome Extension, but I am getting an error when I try to use it:
We detected an application built with production configuration. Angular DevTools only supports development builds.
Can I revert project to dev mode?
Upvotes: 16
Views: 24479
Reputation: 1816
Angular DevTools detects production configuration even if all others are properly defined.
This attribute of your configuration build section will activate Angular DevTools ;)
"optimization": true,
to
"optimization": false,
Upvotes: 2
Reputation: 2827
I had all of those settings and configurations in place in angular.json
.
For me, the problem was the following:
main.ts:
if (environment.production) {
enableProdMode(); // <-- here
}
platformBrowserDynamic()
.bootstrapModule(AppModule)
.catch(err => console.error(err));
And apparently, I changed the production
property of my environment.ts
file at some point in the past, setting production
in there to true
, even in development mode.
Changing it back to false
finally resolved this for me.
Upvotes: 16
Reputation:
Btw: A complete working configuration (further below), and if the configuration is not the problem, then:
ng serve
(if mono repo npx nx serve <projectname>
)You would then see, something like that (depends on your own configuration):
** Angular Live Development Server is
listening on localhost:4200,
open your browser on http://localhost:4200/ **
And you should see:
Last but not least: An example of complete configuration:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"ng14.0.2": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/ng14.0.2",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "ng14.0.2:build:production"
},
"development": {
"browserTarget": "ng14.0.2:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "ng14.0.2:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": []
}
}
}
}
}
}
Upvotes: 5
Reputation: 655
You may be missing a development configuration for your application.
In your angular.json navigate to architect
-> build
-> configurations
and add these lines, below the definition of the production build:
"configurations": {
"production": {
// already there!
},
"development": { // this is new!
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
And to run the build in development mode just type the next command: ng build --configuration development
.
Upvotes: 19