Skip to content

Commit 9f4063b

Browse files
refactor(devtools): provide user with suggestions on why their angular application is not being detected in dev mode (angular#57861)
We've been seeing some reports about Angular DevTools being unable to detect applications running in dev mode. This commit adds more context to the error message displayed when development mode is not detected and offers some possible resolutions. Displays 3 common reasons why DevTools fails to detect an application running in dev mode. Links directly to angular.dev for relevant configurations. Links to the Angular DevTools issue template if none of the suggestions work. PR Close angular#57861
1 parent f5349cb commit 9f4063b

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

devtools/projects/ng-devtools/src/lib/devtools.component.html

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,29 @@
1313
}
1414
} @else {
1515
<p class="text-message" matTooltip="A dev build is when the `optimization` flag is set to `false` in the angular.json config file.">
16-
We detected an application built with production configuration. Angular DevTools only supports development build.
16+
We detected an application built with production configuration. Angular DevTools only supports development builds.
1717
</p>
18+
19+
<div class="ng-dev-mode-causes">
20+
<p>
21+
If this application was built in development mode, please check if the <code>window.ng</code> global object is available in your
22+
application. If it is missing, then something is preventing Angular from running in development mode properly.
23+
</p>
24+
<ul>
25+
<li>
26+
Are you calling <code>enableProdMode()</code> in your application? Read more about <a target="_blank" href="https://angular.dev/api/core/enableProdMode">enableProdMode()</a> on angular.dev.
27+
</li>
28+
<li>
29+
Is <code>"optimization": true</code> set in your angular.json? Read more about <a target="_blank" href="https://angular.dev/reference/configs/workspace-config#optimization-configuration">optimization configuration</a> on angular.dev.
30+
</li>
31+
<li>
32+
Is <code>"defaultConfiguration": "production"</code> set in your angular.json? Read more about <a target="_blank" href="https://angular.dev/tools/cli/environments#using-environment-specific-variables-in-your-app">default configurations</a> on angular.dev.
33+
</li>
34+
</ul>
35+
<p>
36+
If you are still experiencing problems, you can open an issue with a reproduction on our <a target="_blank" href="https://github.com/angular/angular/issues/new?assignees=&labels=&projects=&template=4-devtools.yaml">issue tracker</a>.
37+
</p>
38+
</div>
1839
}
1940
}
2041
@case (AngularStatus.DOES_NOT_EXIST) {

devtools/projects/ng-devtools/src/lib/devtools.component.scss

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,24 @@
215215
color: #000;
216216
}
217217
}
218+
219+
.ng-dev-mode-causes {
220+
font-weight: 500;
221+
font-size: 1.2em;
222+
padding: 1rem;
223+
width: 80%;
224+
margin: auto;
225+
border: 1px solid;
226+
border-radius: 16px;
227+
228+
code {
229+
padding: 2px;
230+
color: lightgreen;
231+
background: #3e3e3e;
232+
border-radius: 5px;
233+
}
234+
235+
li {
236+
margin-bottom: 1rem;
237+
}
238+
}

devtools/projects/ng-devtools/src/lib/devtools_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('DevtoolsComponent', () => {
5555
component.angularIsInDevMode = false;
5656
fixture.detectChanges();
5757
expect(fixture.nativeElement.querySelector('.devtools').textContent).toContain(
58-
'We detected an application built with production configuration. Angular DevTools only supports development build.',
58+
'We detected an application built with production configuration. Angular DevTools only supports development builds.',
5959
);
6060
});
6161

0 commit comments

Comments
 (0)