Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vaadinBuildFrontend fails because Vaadin cannot install node #13623

Closed
kimminger opened this issue Apr 26, 2022 · 7 comments
Closed

vaadinBuildFrontend fails because Vaadin cannot install node #13623

kimminger opened this issue Apr 26, 2022 · 7 comments

Comments

@kimminger
Copy link

Description of the bug

Hey,

we build a Spring Boot App (3.6.1) with Java 17.0.1, Vaadin 23.0.6 configured with gradle.
When i run it in dev mode locally on a Windows Laptop, App can be loaded successfully.

But running this in the ci/cd - pipeline on eclipse-temurin:17-alpine - Image with the following command
./gradlew vaadinBuildFrontend --info --stacktrace

Then i get following error (complete stacktrace omitted):

´´´
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app-server:vaadinPrepareFrontend'.
...
Caused by: java.lang.IllegalStateException: Failed to install Node
...
Unpacking /root/.vaadin/node-v16.14.2-linux-x64.tar.gz into /root/.vaadin/node/tmp
Copying node binary from /root/.vaadin/node/tmp/node-v16.14.2-linux-x64/bin/node to /root/.vaadin/node/node
Extracting npm
Local node installation successful.
Error checking if node is new enough
com.vaadin.flow.server.frontend.FrontendUtils$UnknownVersionException: Unable to detect version of node. Using command /root/.vaadin/node/node --version
´´´

So the downloaded tar can be unpacked, but not successfully called.

Expected behavior

Npm should be installed correctly, so that the Front-End can be build

Minimal reproducible example

@route("")
public class DemoView extends VerticalLayout {

public DemoView() {
    add(
            new H1("Hello Demo!")
    );
}

}

  • run project in ci-pipeline, e.g. gitlab with config-yaml:

image: docker:latest
services:

  • docker:dind

stages:

  • build-frontend

before_script:

  • export GRADLE_USER_HOME=pwd/.gradle
  • chmod +x gradlew

gradle-build-frontend:
image: eclipse-temurin:17-alpine
stage: build-frontend
script: ./gradlew vaadinBuildFrontend --info --stacktrace

fails with:
Couldn't find node. Installing Node and NPM to /root/.vaadin.
Installing node version v14.15.4
Downloading https://nodejs.org/dist/v14.15.4/node-v14.15.4-linux-x64.tar.gz to /root/.vaadin/node-v14.15.4-linux-x64.tar.gz
No proxies configured
No proxy was configured, downloading directly
Unpacking /root/.vaadin/node-v14.15.4-linux-x64.tar.gz into /root/.vaadin/node/tmp
Copying node binary from /root/.vaadin/node/tmp/node-v14.15.4-linux-x64/bin/node to /root/.vaadin/node/node
Extracting NPM
Local node installation successful.
Error checking if node is new enough
com.vaadin.flow.server.frontend.FrontendUtils$UnknownVersionException: Unable to detect version of node. Using command /root/.vaadin/node/node --version
at com.vaadin.flow.server.frontend.FrontendUtils.getVersion(FrontendUtils.java:827)
at com.vaadin.flow.server.frontend.FrontendTools.validateNodeAndNpmVersion(FrontendTools.java:385)
at com.vaadin.gradle.VaadinPrepareFrontendTask.vaadinPrepareFrontend(VaadinPrepareFrontendTask.kt:77)
at java.base@17.0.2/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base@17.0.2/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base@17.0.2/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base@17.0.2/java.lang.reflect.Method.invoke(Method.java:568)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:104)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:58)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:51)

Versions

  • Vaadin / Flow version: 23.0.6
  • Java version: OpenJDK 17.0.1
  • OS version: eclipse-temurin:17-alpine
  • Application Server (if applicable): Spring Boot 2.6.1, Tomcat 9.0.55
@kimminger kimminger changed the title vaadinBuildFront vaadinBuildFrontend failes because Vaadin cannot install node Apr 26, 2022
@kimminger
Copy link
Author

same Problem as in #9004
The problem just disappeared in later version and another solution was to install npm yourself.

@chrisw73
Copy link

"another solution was to install npm yourself." this is NO solution!
We are running into this in a Jenkins build which relies on the npm version installed by the Vaadin Build

@Artur-
Copy link
Member

Artur- commented May 23, 2022

"another solution was to install npm yourself." this is NO solution!
We are running into this in a Jenkins build which relies on the npm version installed by the Vaadin Build

It should always be possible for you to install node as part of your build. Either by downloading and running the Node installer like Vaadin does or by using the appropriate package manager.

If you cannot do it then Vaadin cannot either.

@mcollovati
Copy link
Collaborator

It seems related to #13837, since alpine base image is in use

@chrisw73
Copy link

Solution for Jenkins Users: Place this into your Jenkinsfile
stages { stage('Install tools') { steps { sh 'mvn com.github.eirslett:frontend-maven-plugin:1.12.1:install-node-and-npm -DnodeVersion="v16.15.0" -DnpmVersion="8.10.0"' } }

@kimminger kimminger changed the title vaadinBuildFrontend failes because Vaadin cannot install node vaadinBuildFrontend fails because Vaadin cannot install node May 23, 2022
@dkulczycki
Copy link

I had the same error when building an application in azure / pipeline

[WARNING] Error checking if npm is new enough
com.vaadin.flow.server.frontend.FrontendUtils$UnknownVersionException: Unable to detect version of npm. Using command --no-update-notifier --no-audit --scripts-prepend-node-path=true --version
    at com.vaadin.flow.server.frontend.FrontendUtils.getVersion (FrontendUtils.java:849)
    at com.vaadin.flow.server.frontend.FrontendTools.getNpmVersion (FrontendTools.java:573)
    at com.vaadin.flow.server.frontend.FrontendTools.validateNodeAndNpmVersion (FrontendTools.java:399)
    at com.vaadin.flow.plugin.maven.PrepareFrontendMojo.execute (PrepareFrontendMojo.java:149)

(I also tried to install the version that was built a month ago)

There may be a problem with nodejs version 16.15.1

When I added a step

      - task: NodeTool@0
        inputs:
          versionSpec: '16.x'
          checkLatest: true
        displayName: 'Install Node.js'

problem still existed (nodejs 16.15.1)

but when I set version to 16.15.0 problem stopped occurring

      - task: NodeTool@0
        inputs:
          versionSpec: '16.15.0'
        displayName: 'Install Node.js'

@mcollovati
Copy link
Collaborator

Closing as duplicate of #13837

A PR with a fix is currently under review #14300

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants