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.22k stars 868 forks source link

Bad CPU type in executable with install-node-and-yarn on Mac M1 #961

Closed gcatanese closed 3 years ago

gcatanese commented 3 years ago

I have used version v1.11.2 for some time without problems on Windows but I have now a problem building the same code on the MacBook Pro M1 (Big Sur)

Here is the Maven pom

          <plugin>
                   <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>1.11.2</version>
                <configuration>
                    <workingDirectory>app</workingDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>install node</id>
                        <goals>
                            <goal>install-node-and-yarn</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>${node.version}</nodeVersion>
                            <yarnVersion>${yarn.version}</yarnVersion>
                        </configuration>
                    </execution>
                    <execution>
                        <id>yarn install</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <phase>generate-resources</phase>
                    </execution>
                    <execution>
                        <id>yarn build</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <phase>compile</phase>
                        <configuration>
                            <arguments>build</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

current behavior When packaging (mvn package)the application I get: Bad CPU type in executable

See logs

[INFO] --- frontend-maven-plugin:1.11.2:install-node-and-yarn (install node) @ tweeskyWeb ---
[INFO] Downloading https://nodejs.org/dist/v15.11.0/node-v15.11.0-darwin-x64.tar.gz to /Users/beppecatanese/Data/tools/apache-maven-repository/com/github/eirslett/node/15.11.0/node-15.11.0-darwin-x64.tar.gz
[INFO] No proxies configured
[INFO] No proxy was configured, downloading directly
[INFO] Unpacking /Users/beppecatanese/Data/tools/apache-maven-repository/com/github/eirslett/node/15.11.0/node-15.11.0-darwin-x64.tar.gz into /Users/beppecatanese/Data/source/github/perosa/TweeskyWeb/app/node/tmp
[INFO] Copying node binary from /Users/beppecatanese/Data/source/github/perosa/TweeskyWeb/app/node/tmp/node-v15.11.0-darwin-x64/bin/node to /Users/beppecatanese/Data/source/github/perosa/TweeskyWeb/app/node/node
[INFO] Installed node locally.
[INFO] Installing Yarn version v1.22.10
[INFO] Downloading https://github.com/yarnpkg/yarn/releases/download/v1.22.10/yarn-v1.22.10.tar.gz to /Users/beppecatanese/Data/tools/apache-maven-repository/com/github/eirslett/yarn/1.22.10/yarn-1.22.10.tar.gz
[INFO] No proxies configured
[INFO] No proxy was configured, downloading directly
[INFO] Unpacking /Users/beppecatanese/Data/tools/apache-maven-repository/com/github/eirslett/yarn/1.22.10/yarn-1.22.10.tar.gz into /Users/beppecatanese/Data/source/github/perosa/TweeskyWeb/app/node/yarn
[INFO] Installed Yarn locally.

[INFO] --- frontend-maven-plugin:1.11.2:yarn (yarn build) @ tweeskyWeb ---
[INFO] Running 'yarn build' in /Users/beppecatanese/Data/source/github/perosa/TweeskyWeb/app
[INFO] /Users/beppecatanese/Data/source/github/perosa/TweeskyWeb/app/node/yarn/dist/bin/yarn: line 20: /Users/beppecatanese/Data/source/github/perosa/TweeskyWeb/app/node/node: Bad CPU type in executable
[INFO] /Users/beppecatanese/Data/source/github/perosa/TweeskyWeb/app/node/yarn/dist/bin/yarn: line 20: /Users/beppecatanese/Data/source/github/perosa/TweeskyWeb/app/node/node: Undefined error: 0

Steps to reproduce. Run mvn package. Here is the POM file

      <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>1.11.2</version>
                <configuration>
                    <workingDirectory>app</workingDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>install node</id>
                        <goals>
                            <goal>install-node-and-yarn</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>v12.13.0</nodeVersion>
                            <yarnVersion>v1.22.4</yarnVersion>
                        </configuration>
                    </execution>
                    <execution>
                        <id>yarn install</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <phase>generate-resources</phase>
                    </execution>
                    <execution>
                        <id>yarn build</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <phase>compile</phase>
                        <configuration>
                            <arguments>build</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Frontend-maven-plugin and operating system version. Frontend-Maven-Plugin v1.11.2 MacBook Pro M1 BigSur

eirslett commented 3 years ago

@ajthom90 have you seen this error before?

ajthom90 commented 3 years ago

I have not seen that error before. I haven’t used my ARM Mac for development in some time, so I’m not sure how the latest versions of Node are working on Big Sur on M1.

My first instinct is that maybe @gcatanese doesn’t have Rosetta 2 installed? When I did my testing a couple months back, Node ran great under Rosetta, however that was a couple months ago, and maybe later versions of Node are different. I’d suggest maybe trying different versions of Node. I believe the one I had working was 15.4.0, but I can’t remember for sure.

I can try and do some testing, but I’m currently out of town and won’t be back until on Tuesday, so that is the earliest I could try it.

gcatanese commented 3 years ago

@eirslett @ajthom90 I have installed Rosetta (also upgraded Big Sur but I am not sure it is relevant) and I can now build it.

What was confusing is that (without Rosetta) I was able to run yarn (yarn --version or yarn build) without problems (even using the distribution downloaded by the frontend-maven-plugin), but it would not build during the Maven build.

Thank you very much for looking into it, this can be now closed I believe.