0

我无法部署我的 Angular 8 项目。我使用了 CodeUI 角度模板,并且在 Heroku 部署中构建失败。同样的事情正在 localhost 上工作,但无法在 Heroku 上进行构建。

我正在使用的版本:

  • 角 CLI:8.3.6
  • 节点:10.16.0
  • 角度:8.2.8

出现以下错误:

Build
Detected both "build" and "heroku-postbuild" scripts
Running heroku-postbuild

HireCommit@2.5.2 heroku-postbuild /tmp/build_434f7be8a26abfc4235d95846f4eafd0
g build --aot --prod


Date: 2020-02-10T11:18:59.393Z
Hash: 753b3b69ed4e240fe2ea
Time: 52490ms
chunk {0} runtime.741402d1d47331ce975c.js (runtime) 1.41 kB [entry] [rendered]
chunk {1} main.4af9b61479361f268d39.js (main) 128 bytes [initial] [rendered]
ERROR in node_modules/@coreui/angular/lib/sidebar/app-sidebar.component.d.ts(13,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/@coreui/angular/lib/sidebar/app-sidebar.component.d.ts(14,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/@coreui/angular/lib/sidebar/app-sidebar-nav/app-sidebar-nav-items.component.d.ts(11,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/@coreui/angular/lib/sidebar/app-sidebar-nav/app-sidebar-nav-items.component.d.ts(12,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/@coreui/angular/lib/sidebar/app-sidebar-nav/app-sidebar-nav-link.component.d.ts(15,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/@coreui/angular/lib/sidebar/app-sidebar-nav/app-sidebar-nav-link.component.d.ts(16,9): error TS1086: An accessor cannot be declared in an ambient context.
       chunk {2} polyfills.d64fff5b0a45205ed7b5.js (polyfills) 130 bytes [initial] [rendered]
       chunk {3} polyfills-es5.7f9896f05667ed1b2b2b.js (polyfills-es5) 68.1 kB [initial] [rendered]
       chunk {4} styles.f9d3d53855388a7c759d.css (styles) 578 kB [initial] [rendered]
       chunk {scripts} scripts.b59d910a7125cd182ed3.js (scripts) 471 kB [entry] [rendered]
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! HireCommit@2.5.2 heroku-postbuild: `ng build --aot --prod`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the HireCommit@2.5.2 heroku-postbuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/npmcache.u9GWJ/_logs/2020-02-10T11_18_59_473Z-debug.log

Build failed



           We're sorry this build is failing! You can troubleshoot common issues here:
           https://devcenter.heroku.com/articles/troubleshooting-node-deploys

           If you're stuck, please submit a ticket so we can help:
           https://help.heroku.com/

           Love,
           Heroku

     !     Push rejected, failed to compile Node.js app.
     !     Push failed

你可以在这里找到我的 package.json

4

2 回答 2

1

@coreui/angular v2.9.0 使用 Angular 9 和 TypeScript 3.7

TS1086:无法在环境上下文中声明访问器

您的依赖项中有 typescript v3.4.5,您会受到此问题的影响。TypeScript 3.7 在 .d.ts 文件中发出 get/set 访问器。它可能会导致旧版 TypeScript(如 3.5 及更早版本)发生重大更改。
- TypeScript 3.6 是面向未来的此功能。
- 请参阅:类字段缓解

  1. 将您的项目更新到 Angular 9 https://update.angular.io/和 TypeScript 到 3.6 / 3.7
  2. 另一种选择是锁定 @coreui/angular 对版本 2.5.5 / 2.6.3 的依赖
  3. 或将 @coreui/angular 更新为 2.9.1

@coreui/angular v2.9.1使用 Angular 9 和TypeScript 3.6 - Angular 8 兼容

于 2020-02-10T18:05:11.693 回答
0

我在Bitbucket中遇到了类似的问题(不是在 Heroku 中)。就我而言,我有两个选择。第一个是更新 Angular Project 和 Ts。但对我来说不可能。第二个是更新核心UI。那对我有用。编辑 Package.json 文件为

    "@angular/platform-browser-dynamic": "^8.0.0-rc.2",

     "@angular/router": "^8.0.0-rc.2",

-    "@coreui/angular": "^2.4.5", // remove

+    "@coreui/angular": "2.5.3", // add

     "@coreui/coreui": "^2.1.9",
于 2020-02-23T08:07:50.917 回答