我从有角度的开始(对Asp.Net核心有一点点的经验)。 我想使用.Net内核,因为我喜欢MS的发展方向(而且我对.Net相当熟练)。
我做了什么:
npm update npm -g
)dotnet new angular
npm audit fix
dotnet run
)这在控制台中产生了很多错误:
C:\Users\xxxx\angular-test>dotnet run Hosting environment: Production Content root path: C:\Users\xxxx\angular-test Now listening on: http://localhost:5000 Application started. Press Ctrl+C to shut down. fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0]
An unhandled exception has occurred: Prerendering failed because of error: Error: Cannot find module 'C:\Users\xxxx\angular-test\ClientApp\dist\main-server'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader.js:520:25)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at findBootModule (C:\Users\xxxx\AppData\Local\Temp\uwz4m2yz.rjc:111:17)
at findRenderToStringFunc (C:\Users\xxxx\AppData\Local\Temp\uwz4m2yz.rjc:116:28)
at renderToStringImpl (C:\Users\xxxx\AppData\Local\Temp\uwz4m2yz.rjc:75:51)
at C:\Users\xxxx\AppData\Local\Temp\eikzpvcj.v2i:114:19
at IncomingMessage.<anonymous> (C:\Users\xxxx\AppData\Local\Temp\eikzpvcj.v2i:133:38)
at IncomingMessage.emit (events.js:182:13) Current directory is: C:\Users\xxxx\angular-test
Microsoft.AspNetCore.NodeServices.HostingModels.NodeInvocationException: Prerendering failed because of error: Error: Cannot find module 'C:\Users\xxxx\angular-test\ClientApp\dist\main-server'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader.js:520:25)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at findBootModule (C:\Users\xxxx\AppData\Local\Temp\uwz4m2yz.rjc:111:17)
at findRenderToStringFunc (C:\Users\xxxx\AppData\Local\Temp\uwz4m2yz.rjc:116:28)
at renderToStringImpl (C:\Users\xxxx\AppData\Local\Temp\uwz4m2yz.rjc:75:51)
at C:\Users\xxxx\AppData\Local\Temp\eikzpvcj.v2i:114:19
at IncomingMessage.<anonymous> (C:\Users\xxxx\AppData\Local\Temp\eikzpvcj.v2i:133:38)
at IncomingMessage.emit (events.js:182:13)
这在网页上:
错误。处理您的请求时发生错误。要求编号: 0HLF1EQKVCJ2V:00000001
将开发模式切换到开发环境将显示更多 有关发生的错误的详细信息。
不应在已部署的环境中启用开发环境 应用程序,因为它可能会导致来自 向最终用户显示异常。对于本地调试, 可以通过设置开发环境来启用 ASPNETCORE_ENVIRONMENT环境变量为Development,并且 重新启动应用程序。
我想念什么? 或者您会建议我以Asp.Net核心和有角的6开始一个项目(我喜欢HMR的想法,我希望一切都由asp.net核心(静态资源和服务)托管。
修改
我尝试使用开发环境(与SET ASPNETCORE_ENVIRONMENT=Development
一起使用,但是随后在运行应用程序时它直接崩溃(我不必进入网页):
C:\Users\xxxx\angular-test>dotnet run
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using 'C:\Users\xxxx\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
Application startup exception: System.AggregateException: One or more errors occurred. (Cannot find module './wwwroot/dist/vendor-manifest.json'
Error: Cannot find module './wwwroot/dist/vendor-manifest.json'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader.js:520:25)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at module.exports (C:\Users\xxxx\angular-test\webpack.config.js:37:27)
at createWebpackDevServer (C:\Users\xxxx\angular-test\node_modules\aspnet-webpack\WebpackDevMiddleware.js:214:31)
at createWebpackDevServer (C:\Users\xxxx\AppData\Local\Temp\xwjt2knh.npy:74:50)
at C:\Users\xxxx\AppData\Local\Temp\kn0wvgm3.vrx:114:19
at IncomingMessage.<anonymous> (C:\Users\xxxx\AppData\Local\Temp\kn0wvgm3.vrx:133:38)
at IncomingMessage.emit (events.js:182:13)) ---> Microsoft.AspNetCore.NodeServices.HostingModels.NodeInvocationException: Cannot find module './wwwroot/dist/vendor-manifest.json'