1

There is a problem with amd64 jdk on amd64 windows and maven-frontend-plugin:

When mvn compile is ran, it grabs amd64 version of node.exe, which is expected; then it tries to run npm.cmd install, to install deps.

Problem is that after that, everything fails:

[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.0:npm (npm install) on project {projectName}: Failed to run task: 'npm install' failed. java.io.IOException: Cannot run program "D:\Projects\job\projectPath\target\node\node.exe" (in directory "D:\Projects\job\projectPath\src\main\webapp"): CreateProcess error=193, %1 is not a valid Win32 application -> [Help 1]

In case I run x86 jdk, it doesn't fail and builds as normal.

Is the problem on my side, a bug in node.js, in maven-frontend-plugin or in maven itself?

Ivan
  • 8,508
  • 2
  • 19
  • 30
Mikhail Krutov
  • 670
  • 1
  • 5
  • 29
  • @Ivan, yes, it has nothing to do with java, except its java project, which fails to build with 64bit jdk and works flawlessly with 32bit jdk on amd64 windows installation. Part that fails is indeed in javascript/node.js. – Mikhail Krutov Mar 27 '18 at 17:29
  • Do you have `npm.cmd` file downloaded? If no try to change config for maven-frontend-plugin to use `npm.exe`. https://stackoverflow.com/questions/40390478/createprocess-error-193-1-is-not-a-valid-win32-application-help-1. If its is really the case you need to call different files for different jdks you may need to use maven profiles – Ivan Mar 27 '18 at 17:48
  • yes, it is downloaded; I can't run it by-hand (windows claims it can't be ran if I double-click - "Your system can't run this file" - it or execute it through ps/cmd). Using 32bit jdk for that particular project is no big deal, really; but I'd love to understand why `npm.cmd` fails on 64bit. – Mikhail Krutov Mar 27 '18 at 17:56
  • @Ivan, there is also no "npm.exe" in the archive that I got from maven. Version that this project uses is npm-4.4.5, if that matters; and frontends (or javascript) are really not my department, so low knowledge about that stuff. – Mikhail Krutov Mar 27 '18 at 17:57
  • Could you please add config for `maven-frontend-plugin`? What files do you have in `D:\Projects\job\projectPath\target\node` when build fails? – Ivan Mar 27 '18 at 18:43
  • @Ivan, https://pastebin.com/KBwy88AC is related `pom.xml` bit for that subproject. target\node has: `node.exe` (which is `node-4.4.5-windows-x64.exe`), `npm` (which is a shell script) and `npm.cmd` – Mikhail Krutov Mar 27 '18 at 19:01
  • Have you tried changing `npm` to `npm.cmd`? – Ivan Mar 28 '18 at 03:00
  • Your error message says `%1 is not ...` while your question title says `“node.exe is not ...`. Did you substitute the `%1` yourself to make up the question title? Or did that also appear in an error message? It makes me wonder if quoting in a script went wrong and something tried to use a literal `%1` as a filename to execute. – Peter Cordes Mar 28 '18 at 04:01
  • @PeterCordes, npm.cmd has no differences between x86 and x86_64, also `Cannot run program "D:\Projects\job\projectPath\target\node\node.exe" ` is in the error message. – Mikhail Krutov Mar 28 '18 at 06:58
  • @Ivan yes, I did; no changes. Again, works on x86. – Mikhail Krutov Mar 28 '18 at 06:59
  • What happens if you try to run `D:\Projects\job\projectPath\target\node\node.exe` manually? i.e. directly check if that file is a valid executable, so you know whether its a scripting bug or an actually invalid executable. – Peter Cordes Mar 28 '18 at 12:51
  • It is a valid executable. – Mikhail Krutov Mar 28 '18 at 16:48

2 Answers2

0

What I did, is simply overwrite the node.exe file generated on maven install, by the node.exe file on program files. It works !

Moh Lamine
  • 72
  • 1
  • 9
0

I had the same issue on my Windows 10. The problem was the result of a corrupt node.exe in my Maven repository. I had to delete the node folder from BOTH my project and my .m2 repo:

  1. delete this folder from your maven repository -> .m2\repository\com\github\eirslett
  2. delete this folder from your application -> <MY_PROJECT>\target\node

after both folders deleted, do maven clean

mvn clean package

Hope this helps.

Vikrant Korde
  • 315
  • 2
  • 11