简体   繁体   English

带有Angular 2 main.js路径错误的Asp.net Core

[英]Asp.net Core with Angular 2 main.js Path Error

I am building asp.net core application with Angular 2 with the help of Angular Quickstart. 我正在Angular Quickstart的帮助下使用Angular 2构建asp.net核心应用程序。

Since Asp.Net core application allows wwwroot as a folder, I moved all the dependencies to that folder including node modules. 由于Asp.Net核心应用程序允许wwwroot作为文件夹,因此我将所有依赖项(包括节点模块)移到了该文件夹。

Layout.cshtml : Layout.cshtml

    <script src="/node_modules/core-js/client/shim.min.js"></script>
    <script src="/node_modules/zone.js/dist/zone.js"></script>
    <script src="/node_modules/systemjs/dist/system.src.js"></script>

    <script src="~/src/systemjs.config.js"></script>
    <script>
        System.import('main.js').catch(function (err) { console.error(err); });
    </script>

ts.Config.json : ts.Config.json

{
  "compileOnSave": true,
  "compilerOptions": {
    "importHelpers": true,
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [ "es2015", "dom" ],
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true,
    "removeComments": true,
    "outDir": "wwwroot/src"

  }
}

Now I am facing below error: 现在我面临以下错误:

http://localhost:18929/main.js 404 (Not Found) http:// localhost:18929 / main.js 404(未找到)
(index):45 Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:18929/main.js (索引):45错误:(SystemJS)XHR错误(404未找到)正在加载http:// localhost:18929 / main.js

请尝试在html标头中添加以下内容

<base href="/" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM