javascript - Angular 4,如何修复 "simple deployment"中 html 文件的 404 错误?

标签 javascript angular npm

我正在尝试按照 angular guide 的“可能的最简单部署”部分中指定的方式部署我的应用程序。 我已经通过快速启动设置创建了该项目。为了部署应用程序,我更改了以下文件: index.html、main.ts、systemjs.config.server.js,路径为 https://unpkg.com/ 但我收到 html 模板的 404 错误。例如:

GET http://localhost:3001/app.component.html 404(未找到)zone.js:2616 当我恢复到默认设置时,我的应用程序运行良好。 具体来说,systemjs.config 中的以下部分:

paths: {
  // paths serve as alias
  'npm:': 'node_modules/'
}

app.component.ts

import { Component } from '@angular/core';

@Component({
  selector: 'app',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
})
export class AppComponent {}

在这两种情况下,我都通过 npm start 提供服务。

最佳答案

我认为这是 Angular4 中的一个错误,我有时也遇到这个错误。 通过在 main.ts 中添加以下内容来解决: 导入 'zone.js/dist/zone';

关于javascript - Angular 4,如何修复 "simple deployment"中 html 文件的 404 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45216485/

相关文章:

node.js - 什么是 har-validator,我该如何解决这个问题

javascript - 预编译angular js模板加速应用启动

javascript - 使用 ember-data-url-templates 的 EmberJS 自定义适配器

javascript - 在 JavaScript 中,如何按 asc/desc 对数组数组进行排序

javascript - 如何使用 browserify 和 gulp 输出多个包

javascript - create-react-app 安装报告了 NPM 漏洞,我应该做些什么吗?

javascript - linux 共享库可以打开、显示和 printf 到终端吗?

javascript - 从字符串中删除特殊字符并将每个字符串变成数组项

angular - 在 Angular 2 typescript 中异步自动保存

javascript - 从字符串中删除 html 实体以修复 JSON 错误中的意外标记