我刚刚创建了一个新的Angular应用,并将其转换为Angular Universal。当我使用npm run dev:ssr运行项目时,我在终端中得到以下错误:
ERROR Error: Uncaught (in promise): Error: NG04002
Error: NG04002
at Recognizer.noMatchError (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:2343326)
at D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:2343696
at D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:514891
at OperatorSubscriber2._this._error (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:503575)
at OperatorSubscriber2.Subscriber2.error (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:457318)
at OperatorSubscriber2.Subscriber2._error (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:457784)
at OperatorSubscriber2.Subscriber2.error (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:457318)
at OperatorSubscriber2.Subscriber2._error (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:457784)
at OperatorSubscriber2.Subscriber2.error (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:457318)
at OperatorSubscriber2.Subscriber2._error (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:457784)
at resolvePromise (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:733524)
at resolvePromise (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:732497)
at D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:735394
at _ZoneDelegate.invokeTask (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:719497)
at Object.onInvokeTask (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:912531)
at _ZoneDelegate.invokeTask (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:719387)
at Zone3.runTask (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:712485)
at drainMicroTaskQueue (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:722734) {
rejection: RuntimeError: NG04002
at Recognizer.noMatchError (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:2343326)
at D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:2343696
at D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:514891
at OperatorSubscriber2._this._error (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:503575)
at OperatorSubscriber2.Subscriber2.error (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:457318)
at OperatorSubscriber2.Subscriber2._error (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:457784)
at OperatorSubscriber2.Subscriber2.error (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:457318)
at OperatorSubscriber2.Subscriber2._error (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:457784)
at OperatorSubscriber2.Subscriber2.error (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:457318)
at OperatorSubscriber2.Subscriber2._error (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:457784) {
code: 4002
},
promise: ZoneAwarePromise [Promise] {
__zone_symbol__state: 0,
__zone_symbol__value: RuntimeError: NG04002
at Recognizer.noMatchError (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:2343326)
at D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:2343696
at D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:514891
at OperatorSubscriber2._this._error (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:503575)
at OperatorSubscriber2.Subscriber2.error (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:457318)
at OperatorSubscriber2.Subscriber2._error (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:457784)
at OperatorSubscriber2.Subscriber2.error (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:457318)
at OperatorSubscriber2.Subscriber2._error (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:457784)
at OperatorSubscriber2.Subscriber2.error (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:457318)
at OperatorSubscriber2.Subscriber2._error (D:\MyProjects\PROJECTNAME\dist\PROJECTNAME\server\main.js:1:457784) {
code: 4002
}
},
zone: <ref *1> Zone3 {
_parent: Zone3 {
_parent: null,
_name: '<root>',
_properties: {},
_zoneDelegate: [_ZoneDelegate]
},
_name: 'angular',
_properties: { isAngularZone: true },
_zoneDelegate: <ref *2> _ZoneDelegate {
_taskCounts: [Object],
zone: [Circular *1],
_parentDelegate: [_ZoneDelegate],
_forkZS: null,
_forkDlgt: null,
_forkCurrZone: null,
_interceptZS: null,
_interceptDlgt: null,
_interceptCurrZone: null,
_invokeZS: [Object],
_invokeDlgt: [_ZoneDelegate],
_invokeCurrZone: [Circular *1],
_handleErrorZS: [Object],
_handleErrorDlgt: [_ZoneDelegate],
_handleErrorCurrZone: [Circular *1],
_scheduleTaskZS: [Object],
_scheduleTaskDlgt: [_ZoneDelegate],
_scheduleTaskCurrZone: [Circular *1],
_invokeTaskZS: [Object],
_invokeTaskDlgt: [_ZoneDelegate],
_invokeTaskCurrZone: [Circular *1],
_cancelTaskZS: [Object],
_cancelTaskDlgt: [_ZoneDelegate],
_cancelTaskCurrZone: [Circular *1],
_hasTaskZS: [Object],
_hasTaskDlgt: [_ZoneDelegate],
_hasTaskDlgtOwner: [Circular *2],
_hasTaskCurrZone: [Circular *1]
}
},
task: ZoneTask {
_zone: <ref *1> Zone3 {
_parent: [Zone3],
_name: 'angular',
_properties: [Object],
_zoneDelegate: [_ZoneDelegate]
},
runCount: 0,
_zoneDelegates: null,
_state: 'notScheduled',
type: 'microTask',
source: 'Promise.then',
data: ZoneAwarePromise [Promise] {
__zone_symbol__state: 0,
__zone_symbol__value: [RuntimeError]
},
scheduleFn: undefined,
cancelFn: undefined,
callback: [Function (anonymous)],
invoke: [Function (anonymous)]
}
}
字符串
项目本身确实编译成功,并且可以工作,但是这个错误仍然存在于终端中。
我试着在谷歌和这里找到解决方案,但所有提供的解决方案都与我遇到的问题密切相关。
2条答案
按热度按时间hfyxw5xn1#
它似乎你只是有一个问题,在一个routerLink值与一个不存在的路线。
这个错误经常发生在你把链接不是从根开始的时候,因为你更有可能在路由上犯错误。
试着改变路线:
字符串
到
型
4uqofj5v2#
我有同样的错误。发生的是轻微的,但它激怒了我。我发现的是this issue。
我好像有一些
()
的网址,你可以看看有没有。