当我将 MatProgressSpinnerModule 加载到 app.module.ts 中时,我收到“stacktrace”为空的 NG0203 错误:
tQ https://localhost:44378/client/main.js?v=tGcUggioS9SQmuEwtHgBh_nWyK0V2FItGwwRHNtEq90:1
re https://localhost:44378/client/main.js?v=tGcUggioS9SQmuEwtHgBh_nWyK0V2FItGwwRHNtEq90:1
fac https://localhost:44378/client/main.js?v=tGcUggioS9SQmuEwtHgBh_nWyK0V2FItGwwRHNtEq90:1
hydrate https://localhost:44378/client/main.js?v=tGcUggioS9SQmuEwtHgBh_nWyK0V2FItGwwRHNtEq90:1
get https://localhost:44378/client/main.js?v=tGcUggioS9SQmuEwtHgBh_nWyK0V2FItGwwRHNtEq90:1
_resolveInjectorDefTypes https://localhost:44378/client/main.js?v=tGcUggioS9SQmuEwtHgBh_nWyK0V2FItGwwRHNtEq90:1
_resolveInjectorDefTypes https://localhost:44378/client/main.js?v=tGcUggioS9SQmuEwtHgBh_nWyK0V2FItGwwRHNtEq90:1
PM https://localhost:44378/client/main.js?v=tGcUggioS9SQmuEwtHgBh_nWyK0V2FItGwwRHNtEq90:1
create https://localhost:44378/client/main.js?v=tGcUggioS9SQmuEwtHgBh_nWyK0V2FItGwwRHNtEq90:1
wA https://localhost:44378/client/main.js?v=tGcUggioS9SQmuEwtHgBh_nWyK0V2FItGwwRHNtEq90:1
invoke https://localhost:44378/client/polyfills.js:1
onInvoke https://localhost:44378/client/main.js?v=tGcUggioS9SQmuEwtHgBh_nWyK0V2FItGwwRHNtEq90:1
invoke https://localhost:44378/client/polyfills.js:1
run https://localhost:44378/client/polyfills.js:1
run https://localhost:44378/client/main.js?v=tGcUggioS9SQmuEwtHgBh_nWyK0V2FItGwwRHNtEq90:1
bootstrapModuleFactory https://localhost:44378/client/main.js?v=tGcUggioS9SQmuEwtHgBh_nWyK0V2FItGwwRHNtEq90:1
wA https://localhost:44378/client/main.js?v=tGcUggioS9SQmuEwtHgBh_nWyK0V2FItGwwRHNtEq90:1
invoke https://localhost:44378/client/polyfills.js:1
run https://localhost:44378/client/polyfills.js:1
F https://localhost:44378/client/polyfills.js:1
invokeTask https://localhost:44378/client/polyfills.js:1
runTask https://localhost:44378/client/polyfills.js:1
L https://localhost:44378/client/polyfills.js:1
promise callback*d https://localhost:44378/client/polyfills.js:1
scheduleTask https://localhost:44378/client/polyfills.js:1
scheduleTask https://localhost:44378/client/polyfills.js:1
scheduleMicroTask https://localhost:44378/client/polyfills.js:1
F https://localhost:44378/client/polyfills.js:1
then https://localhost:44378/client/polyfills.js:1
bootstrapModule https://localhost:44378/client/main.js?v=tGcUggioS9SQmuEwtHgBh_nWyK0V2FItGwwRHNtEq90:1
636 https://localhost:44378/client/main.js?v=tGcUggioS9SQmuEwtHgBh_nWyK0V2FItGwwRHNtEq90:1
n https://localhost:44378/client/runtime.js:1
<anonymous> https://localhost:44378/client/main.js?v=tGcUggioS9SQmuEwtHgBh_nWyK0V2FItGwwRHNtEq90:1
a https://localhost:44378/client/runtime.js:1
<anonymous> https://localhost:44378/client/main.js?v=tGcUggioS9SQmuEwtHgBh_nWyK0V2FItGwwRHNtEq90:1
app.module.ts:
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { HttpClientModule } from "@angular/common/http";
import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { AppComponent } from './app.component';
import { SongbookService } from './services/songbookService';
import router from './router';
import { InterceptorService } from './services/InterceptorService';
import { SpinnerService } from './services/spinnerService';
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
HttpClientModule,
BrowserAnimationsModule,
MatProgressSpinnerModule,
router
],
providers: [
SongbookService,
{ provide: HTTP_INTERCEPTORS, useClass: InterceptorService, multi: true },
SpinnerService
],
bootstrap: [AppComponent]
})
export class AppModule { }
我不知道如何修复它,当我在 NgModule 导入中 rem MatProgressSpinnerModule 时 - 错误没有出现。 ngx-spinner 也有同样的问题。
如果重要的话,.NET 应用程序中的 SPA
我也经历过一个错误“NG0203ject()必须从注入上下文调用”,一天又一天,而没有真正改变一些东西。
我偶然发现了以下适用于我的案例的解决方案: https://stackoverflow.com/a/61801741/18578004
建议是调整 tsconfig.json 中的编译器选项,添加 Angular 模块的路径,如下所示:
{
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"paths": {
//[...]
"@angular/*": [ "./node_modules/@angular/*"]
},
//[...]
}
}
希望有帮助...
当我尝试在 Agular 16 中使用组件外的
effect
时,也会发生这种情况。
今天这个错误发生在我的产品版本上。开发版本很好。 我的错误是,tsconfig.app.json -> compilerOptions -> paths 中项目外部库的一些调试路径。