我有角度的应用程序,我想用 Heroku 部署它,我使用以下命令在本地构建了我的项目:
node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng build
一切都很好。 我使用以下命令在本地运行我的项目:
node server.js
然后我尝试通过 heroku 部署该应用程序 - github 当我尝试部署分支时,我遇到了错误,这是错误的日志:
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)
Resolving node version 12.x...
Downloading and installing node 12.18.2...
Using default npm version: 6.14.5
-----> Installing dependencies
Installing node modules
> fsevents@1.2.12 install /tmp/build_3c5cb0395de8e0d3963273d354182105/node_modules/webpack-dev-server/node_modules/fsevents
> node-gyp rebuild
make: Entering directory '/tmp/build_3c5cb0395de8e0d3963273d354182105/node_modules/webpack-dev-server/node_modules/fsevents/build'
SOLINK_MODULE(target) Release/obj.target/.node
COPY Release/.node
make: Leaving directory '/tmp/build_3c5cb0395de8e0d3963273d354182105/node_modules/webpack-dev-server/node_modules/fsevents/build'
> fsevents@1.2.12 install /tmp/build_3c5cb0395de8e0d3963273d354182105/node_modules/watchpack/node_modules/fsevents
> node-gyp rebuild
make: Entering directory '/tmp/build_3c5cb0395de8e0d3963273d354182105/node_modules/watchpack/node_modules/fsevents/build'
SOLINK_MODULE(target) Release/obj.target/.node
COPY Release/.node
make: Leaving directory '/tmp/build_3c5cb0395de8e0d3963273d354182105/node_modules/watchpack/node_modules/fsevents/build'
> core-js@3.6.4 postinstall /tmp/build_3c5cb0395de8e0d3963273d354182105/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> @angular/cli@9.1.1 postinstall /tmp/build_3c5cb0395de8e0d3963273d354182105/node_modules/angular-datatables/node_modules/@angular/cli
> node ./bin/postinstall/script.js
> @angular/cli@9.1.4 postinstall /tmp/build_3c5cb0395de8e0d3963273d354182105/node_modules/@angular/cli
> node ./bin/postinstall/script.js
> core-js@2.6.11 postinstall /tmp/build_3c5cb0395de8e0d3963273d354182105/node_modules/babel-runtime/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> igniteui-cli@5.0.1 postinstall /tmp/build_3c5cb0395de8e0d3963273d354182105/node_modules/igniteui-cli
> node ./scripts/install.js
> tsp-project-ui@0.0.0 postinstall /tmp/build_3c5cb0395de8e0d3963273d354182105
> ng build --prod
Warning: Entry point 'agm-direction' contains deep imports into '/tmp/build_3c5cb0395de8e0d3963273d354182105/node_modules/@agm/core/services/google-maps-types'. This is probably not a problem, but may cause the compilation of entry points to be out of order.
Compiling @angular/core : es2015 as esm2015
Compiling @angular/common : es2015 as esm2015
Compiling @angular/cdk/platform : es2015 as esm2015
Compiling @angular/cdk/bidi : es2015 as esm2015
Compiling @angular/platform-browser : es2015 as esm2015
Compiling @angular/animations : es2015 as esm2015
Compiling @angular/cdk/keycodes : es2015 as esm2015
Compiling @angular/cdk/observers : es2015 as esm2015
Compiling @angular/animations/browser : es2015 as esm2015
Compiling @angular/cdk/a11y : es2015 as esm2015
Compiling @angular/forms : es2015 as esm2015
Compiling @angular/platform-browser/animations : es2015 as esm2015
Compiling @angular/material/core : es2015 as esm2015
Compiling @angular/cdk/collections : es2015 as esm2015
Compiling @angular/cdk/scrolling : es2015 as esm2015
Compiling @angular/cdk/portal : es2015 as esm2015
Compiling @angular/cdk/overlay : es2015 as esm2015
Compiling @angular/material/form-field : es2015 as esm2015
Compiling @angular/common/http : es2015 as esm2015
Compiling @angular/cdk/layout : es2015 as esm2015
Compiling @angular/material/button : es2015 as esm2015
Compiling @angular/flex-layout/core : es2015 as esm2015
Compiling @angular/cdk/text-field : es2015 as esm2015
Compiling @angular/material/icon : es2015 as esm2015
Compiling @angular/material/input : es2015 as esm2015
Compiling @angular/material/select : es2015 as esm2015
Compiling @angular/material/tooltip : es2015 as esm2015
Compiling @angular/router : es2015 as esm2015
Compiling @agm/core : es2015 as esm2015
Compiling @angular/flex-layout/extended : es2015 as esm2015
Compiling @angular/flex-layout/flex : es2015 as esm2015
Compiling @angular/flex-layout/grid : es2015 as esm2015
Compiling ngx-progressbar : es2015 as esm2015
Compiling @angular/material/dialog : es2015 as esm2015
Compiling @angular/cdk/accordion : es2015 as esm2015
Compiling @angular/material/divider : es2015 as esm2015
Compiling @angular/cdk/stepper : es2015 as esm2015
Compiling @angular/cdk/table : es2015 as esm2015
Compiling @angular/material/paginator : es2015 as esm2015
Compiling @angular/material/sort : es2015 as esm2015
Compiling @angular/cdk/tree : es2015 as esm2015
Compiling @angular/core/testing : es2015 as esm2015
Compiling @angular/platform-browser-dynamic : es2015 as esm2015
Compiling @angular/platform-browser/testing : es2015 as esm2015
Compiling @angular/compiler/testing : es2015 as esm2015
Compiling @angular/common/testing : es2015 as esm2015
Compiling @angular/flex-layout : es2015 as esm2015
Compiling @angular/animations/browser/testing : es2015 as esm2015
Compiling @angular/cdk/clipboard : es2015 as esm2015
Compiling @angular/cdk/drag-drop : es2015 as esm2015
Compiling @angular/common/http/testing : es2015 as esm2015
Compiling @angular/material/autocomplete : es2015 as esm2015
Compiling @angular/material/badge : es2015 as esm2015
Compiling @angular/material/bottom-sheet : es2015 as esm2015
Compiling @angular/material/button-toggle : es2015 as esm2015
Compiling @angular/material/card : es2015 as esm2015
Compiling @angular/material/checkbox : es2015 as esm2015
Compiling @angular/material/chips : es2015 as esm2015
Compiling @angular/material/datepicker : es2015 as esm2015
Compiling @angular/material/expansion : es2015 as esm2015
Compiling @angular/material/grid-list : es2015 as esm2015
Compiling @angular/material/icon/testing : es2015 as esm2015
Compiling @angular/material/list : es2015 as esm2015
Compiling @angular/material/menu : es2015 as esm2015
Compiling @angular/material/progress-bar : es2015 as esm2015
Compiling @angular/material/progress-spinner : es2015 as esm2015
Compiling @angular/material/radio : es2015 as esm2015
Compiling @angular/material/sidenav : es2015 as esm2015
Compiling @angular/material/slide-toggle : es2015 as esm2015
Compiling @angular/material/slider : es2015 as esm2015
Compiling @angular/material/snack-bar : es2015 as esm2015
Compiling @angular/material/stepper : es2015 as esm2015
Compiling @angular/material/table : es2015 as esm2015
Compiling @angular/material/tabs : es2015 as esm2015
Compiling @angular/material/toolbar : es2015 as esm2015
Compiling @angular/material/tree : es2015 as esm2015
Compiling @angular/material-moment-adapter : es2015 as esm2015
Compiling @angular/platform-browser-dynamic/testing : es2015 as esm2015
Compiling @angular/router/testing : es2015 as esm2015
Compiling @angular-material-extensions/google-maps-autocomplete : es2015 as esm2015
Compiling @ng-bootstrap/ng-bootstrap : es2015 as esm2015
Compiling agm-direction : es2015 as esm2015
Compiling angular-datatables : module as esm5
Warning: Unable to fully load /tmp/build_3c5cb0395de8e0d3963273d354182105/node_modules/angular-datatables/src/angular-datatables.directive.js for source-map flattening: ENOENT: no such file or directory, open '/tmp/build_3c5cb0395de8e0d3963273d354182105/node_modules/angular-datatables/src/angular-datatables.directive.js.map'
Warning: Unable to fully load /tmp/build_3c5cb0395de8e0d3963273d354182105/node_modules/angular-datatables/src/angular-datatables.module.js for source-map flattening: ENOENT: no such file or directory, open '/tmp/build_3c5cb0395de8e0d3963273d354182105/node_modules/angular-datatables/src/angular-datatables.module.js.map'
Warning: Unable to fully load /tmp/build_3c5cb0395de8e0d3963273d354182105/node_modules/angular-datatables/index.js for source-map flattening: ENOENT: no such file or directory, open '/tmp/build_3c5cb0395de8e0d3963273d354182105/node_modules/angular-datatables/index.js.map'
Compiling angularx-social-login : es2015 as esm2015
Compiling igniteui-angular : es2015 as esm2015
Compiling ng2-file-upload : es2015 as esm2015
Compiling ngx-perfect-scrollbar : es2015 as esm2015
Compiling ngx-progressbar/http : es2015 as esm2015
Compiling ngx-progressbar/router : es2015 as esm2015
WARNING in Exceeded maximum budget for /tmp/build_3c5cb0395de8e0d3963273d354182105/src/app/AuthenticationManagement/dashboard/dashboard.component.css. Budget 6 kB was not met by 154 kB with a total of 160 kB.
WARNING in Exceeded maximum budget for /tmp/build_3c5cb0395de8e0d3963273d354182105/src/app/AuthenticationManagement/login/login.component.css. Budget 6 kB was not met by 154 kB with a total of 160 kB.
ERROR in src/app/AuthenticationManagement/register/register.component.ts:23:14 - error NG6007: The Component 'RegisterComponent' is declared by more than one NgModule.
23 export class RegisterComponent implements OnInit {
~~~~~~~~~~~~~~~~~
src/app/app.module.ts:105:5
105 RegisterComponent,
~~~~~~~~~~~~~~~~~
'RegisterComponent' is listed in the declarations of the NgModule 'AppModule'.
src/app/services/Module/authentiction/authentiction.module.ts:14:5
14 RegisterComponent
~~~~~~~~~~~~~~~~~
'RegisterComponent' is listed in the declarations of the NgModule 'AuthentictionModule'.
src/app/AuthenticationManagement/login/login.component.ts:18:14 - error NG6007: The Component 'LoginComponent' is declared by more than one NgModule.
18 export class LoginComponent implements OnInit {
~~~~~~~~~~~~~~
src/app/app.module.ts:104:5
104 LoginComponent,
~~~~~~~~~~~~~~
'LoginComponent' is listed in the declarations of the NgModule 'AppModule'.
src/app/services/Module/authentiction/authentiction.module.ts:13:6
13 LoginComponent,
~~~~~~~~~~~~~~
'LoginComponent' is listed in the declarations of the NgModule 'AuthentictionModule'.
ERROR in Exceeded maximum budget for /tmp/build_3c5cb0395de8e0d3963273d354182105/src/app/AuthenticationManagement/dashboard/dashboard.component.css. Budget 10 kB was not met by 150 kB with a total of 160 kB.
ERROR in Exceeded maximum budget for /tmp/build_3c5cb0395de8e0d3963273d354182105/src/app/AuthenticationManagement/login/login.component.css. Budget 10 kB was not met by 150 kB with a total of 160 kB.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! tsp-project-ui@0.0.0 postinstall: `ng build --prod`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the tsp-project-ui@0.0.0 postinstall 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.BHvwU/_logs/2020-07-07T08_57_23_736Z-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
Some possible problems:
- Node version not specified in package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
我该如何解决它?
LoginComponent 和 RegisterComponent 在两个模块(AuthentictionModule 和 AppModule(中声明。要解决此问题,您必须在其中一个模块中声明这些组件,而不是在两个模块中声明一个组件。之后,您可以在本地尝试ng build
以检查是否存在其他错误。此外,如果您在 Heroku 上构建作为生产模式,您可以使用ng build --prod
进行本地检查。