Angular2&的“对节点模块的调用失败,并显示错误". ASP.NET [英] "Call to Node module failed with error"s with Angular2 & ASP.NET

查看:89
本文介绍了Angular2&的“对节点模块的调用失败,并显示错误". ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的ASP.NET Core Angular 2网络应用程序出现间歇性异常:

I'm getting an intermittent exception with my ASP.NET Core Angular 2 web-app:

Exception: Call to Node module failed with error: Error: This method is not implemented in Parse5DomAdapter: Parse5DomAdapter#getCookie
 at _notImplemented (D:\Projects\MyProject\MyProject\node_modules\angular2-platform-node\parse5-adapter.js:22:12)
 at Parse5DomAdapter.getCookie (D:\Projects\MyProject\MyProject\node_modules\angular2-platform-node\parse5-adapter.js:641:15)
 at CookieXSRFStrategy.configureRequest (D:\Projects\MyProject\MyProject\node_modules\@angular\http\bundles\http.umd.js:1597:92)
 at XHRBackend.createConnection (D:\Projects\MyProject\MyProject\node_modules\@angular\http\bundles\http.umd.js:1637:32)
 at httpRequest (D:\Projects\MyProject\MyProject\node_modules\@angular\http\bundles\http.umd.js:1975:24)
 at Http.get (D:\Projects\MyProject\MyProject\node_modules\@angular\http\bundles\http.umd.js:2086:20)
 at ApiService.getChatMessages (D:\Projects\MyProject\MyProject\ClientApp\dist\main-server.js:557:20)
 at ChatPageComponent.ngOnInit (D:\Projects\MyProject\MyProject\ClientApp\dist\main-server.js:513:23)
 at AppView._View_ChatPageComponent_Host0.detectChangesInternal (ChatPageComponent_Host.ngfactory.js:30:86)
 at AppView.detectChanges (D:\Projects\MyProject\MyProject\node_modules\@angular\core\bundles\core.umd.js:9566:18)

MoveNext

我认为这与MVC视图有关,如错误所示:

I believe it's something to do with the MVC views, as the error shows:

MoveNext in Index.cshtml

1.@{
2.    ViewData["Title"] = "Home Page";
3.}
4.
5.<app asp-prerender-module="ClientApp/dist/main-server">Loading...</app>
6.
7.<script src="~/dist/vendor.js" asp-append-version="true"></script>
8.@section scripts {

哪个是我的index.cshtml中的代码.

Which is code in my index.cshtml.

启动项目后似乎很早就发生了.一切正常,或者在执行任何导航时加载主页后,都会引发错误.

It seems to happen early on after launching the project. It all either works fine, or after loading the home page when any navagation is performed it throws an error.

我可以强迫它产生错误.我有4个导航目的地:

I can force it to produce the error. I have 4 navagation destinations:

http://localhost:49954/home
http://localhost:49954/counter
http://localhost:49954/fetch-data
http://localhost:49954/chat-page

所有这些都是从Visual Studio Angular 2模板设置的.如果我回到家,一切都很好,并且如果有一段时间可以加载,我可以浏览其他页面.但是,如果我输入其他任何页面的URL,则每次都会产生此错误.

That were all set up from the Visual Studio Angular 2 template. If I refresh home, everything is fine, and if it's had a chance to load for a while I can navagate to the other pages. However if I type in the url for any of the other pages, it produces this error every single time.

另外,有趣的是,它与http://localhost:49954/counter会产生稍微不同的错误.在我的计数器页面中,我使用了Angular Material Design组件:

Also, interestingly, it produces a slightly different error with http://localhost:49954/counter. In my counter page I use an Angular Material Design component:

<div class="mine">
    <h2>
        Counter Test
    </h2>
    <p>This is a simple example of an Angular 2 component.</p>
    <p>Current count:<strong>{{ currentCount }}</strong></p>
    <button md-raised-button (click)="incrementCounter()">Increment</button>
</div>

除了上面的错误外,它是类似于调用节点"模块失败的错误,但在材料设计上:

and instead of the above error, it's a similar Call to Node module failed error, but in material design:

Exception: Call to Node module failed with error: Error: Uncaught (in promise): ReferenceError: document is not defined
 ReferenceError: document is not defined
 at new RippleRenderer (D:\Projects\MyProject\MyProject\node_modules\@angular\material\material.umd.js:193:31)

推荐答案

这对我有用.更改:

<app asp-prerender-module="ClientApp/dist/main-server">Loading...</app>

<app asp-ng2-prerender-module="ClientApp/dist/main-server">Loading...</app>

在index.html

in the index.html

这篇关于Angular2&amp;的“对节点模块的调用失败,并显示错误". ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆