eirslett / frontend-maven-plugin

"Maven-node-grunt-gulp-npm-node-plugin to end all maven-node-grunt-gulp-npm-plugins." A Maven plugin that downloads/installs Node and NPM locally, runs NPM install, Grunt, Gulp and/or Karma.
Apache License 2.0
4.23k stars 868 forks source link

Build Failure During Heroku Deployment #893

Closed AlexNenartovich closed 4 years ago

AlexNenartovich commented 4 years ago

My first time posting an issue on GitHub, I'll try to follow all the rules. I am trying to deploy an application on Heroku (SpringBoot + AWS RDS + React) from GitHub repo. When running Maven Build from Eclipse everything works fine (a jar file is successfully created). However, after connecting to my repo from Heroku and trying to deploy the app, the build fails with the following error(s):

[ERROR] module.js:540 [ERROR] throw err; [ERROR] ^ [ERROR] [ERROR] Error: Cannot find module 'jest-worker' [ERROR] at Function.Module._resolveFilename (module.js:538:15) [ERROR] at Function.Module._load (module.js:468:25) [ERROR] at Module.require (module.js:587:17) [ERROR] at require (internal/module.js:11:18) [ERROR] at Object. (/tmp/build_dafe44b94faf466b36a2e61a29d743af/frontend/node_modules/terser-webpack-plugin/dist/TaskRunner.js:12:42) [ERROR] at Module._compile (module.js:643:30) [ERROR] at Object.Module._extensions..js (module.js:654:10) [ERROR] at Module.load (module.js:556:32) [ERROR] at tryModuleLoad (module.js:499:12) [ERROR] at Function.Module._load (module.js:491:3) [ERROR] npm ERR! code ELIFECYCLE [ERROR] npm ERR! errno 1 [ERROR] npm ERR! smart-form@0.1.0 build: react-scripts build [ERROR] npm ERR! Exit status 1 [ERROR] npm ERR! [ERROR] npm ERR! Failed at the smart-form@0.1.0 build script. [ERROR] npm ERR! This is probably not a problem with npm. There is likely additional logging output above. [ERROR] [ERROR] npm ERR! A complete log of this run can be found in: [ERROR] npm ERR! /app/.npm/_logs/2020-04-03T23_35_16_347Z-debug.log [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 42.883 s [INFO] Finished at: 2020-04-03T23:35:16Z [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.6:npm (npm run build) on project demo: Failed to run task: 'npm run build' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException ! ERROR: Failed to build app with Maven We're sorry this build is failing! If you can't find the issue in application code, please submit a ticket so we can help: https://help.heroku.com/ ! Push rejected, failed to compile Java app. ! Push failed

So it starts with module "jest-worker" not found, however the dependency is in package.json. Using frontend-maven-plugin version 1., node version v10.13.0 and Mac OS Catalina. Will be happy to provide any additional info. Thank you in advance!

eirslett commented 4 years ago

Did you remember to run npm install (or npm ci) as part of the build?

AlexNenartovich commented 4 years ago

Did you remember to run npm install (or npm ci) as part of the build?

Thank you for your reply. I actually fixed this particular issue by wrapping plugins tag inside of the build tag with pluginManagement tag. Not sure why it is necessary but the project builds successfully now. However, after deployment when I visit my app url I get an error "no main manifest attribute" in the jar file. I guess it's a different issue though and I should close this one.

eirslett commented 4 years ago

Sounds like a Spring Boot issue to me.

AlexNenartovich commented 4 years ago

Sounds like a Spring Boot issue to me.

I doubt it because everything runs fine if I run Maven Build... directly from Eclipse and build the jar file this way. The "no main manifest attribute" issue happens only when the jar is built by Heroku. The build completes successfully but when I try to view the app I get that error on the app page. I think Heroku may be creating a non-executable jar file.

AlexNenartovich commented 4 years ago

Reconfigured my pom.xml file and the project built successfully.