【问题标题】:Angular 5. ng build --prod works. Deployed application failsAngular 5. ng build --prod 有效。部署的应用程序失败
【发布时间】:2019-02-14 16:59:45
【问题描述】:

在上次 npm 更新之前一切正常

http://projects.mcrit.com/dist/

我正在使用:

Angular CLI: 1.6.56
Node: 8.9.4
OS: linux x64
Angular: 5.2.1
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router

@angular/cdk: 5.1.0
@angular/cli: 1.6.5
@angular/material: 5.1.0
@angular-devkit/build-optimizer: 0.0.41
@angular-devkit/core: 0.0.28
@angular-devkit/schematics: 0.0.51
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.5
@schematics/angular: 0.1.16
typescript: 2.6.2
webpack: 3.10.0

我可以使用 ng build -prod 编译应用程序,但在 apache 服务器上部署的应用程序失败。

Chrome 消息是:Uncaught SyntaxError: Unexpected token , Firefox 消息是:SyntaxError: missing ) after for-loop control

没有 -prod 构建在服务器上工作正常

有人可以帮帮我吗?

【问题讨论】:

  • 请提供出现错误的组件代码示例
  • 我不确定你的意思。错误在 main.xxxxxxxxxxxx.js 文件中
  • 检查 ng serve --prod --source-map
  • 编译成功。但是 localhost:4200 作为编译和部署的版本失败。

标签: angular npm


【解决方案1】:

尝试在 index.html 中将 <base href="./"> 更改为 <base href="/"><base href="/dist/">

【讨论】:

  • 找不到 js... 包含 与 ./ 相同的错误
猜你喜欢
  • 1970-01-01
  • 2018-08-08
  • 1970-01-01
  • 2019-11-05
  • 2020-10-03
  • 1970-01-01
  • 2018-01-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多