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

NPM version check failure #9004

Closed
RalfNaujokat opened this issue Sep 8, 2020 · 19 comments
Closed

NPM version check failure #9004

RalfNaujokat opened this issue Sep 8, 2020 · 19 comments

Comments

@RalfNaujokat
Copy link

The plugin tries to verify the version of npm,
but uses node for this. That is failing of course.

[INFO] --- vaadin-maven-plugin:17.0.0:prepare-frontend (default) @ appointments ---
[INFO] Couldn't find npm. Installing Node and NPM to /home/local-admin/.vaadin.
[INFO] Installing node version v12.16.0
[INFO] Downloading https://nodejs.org/dist/v12.16.0/node-v12.16.0-linux-x64.tar.gz to /home/local-admin/.vaadin/node-v12.16.0-linux-x64.tar.gz
[INFO] No proxies configured
[INFO] No proxy was configured, downloading directly
[INFO] Unpacking /home/local-admin/.vaadin/node-v12.16.0-linux-x64.tar.gz into /home/local-admin/.vaadin/node/tmp
[INFO] Copying node binary from /home/local-admin/.vaadin/node/tmp/node-v12.16.0-linux-x64/bin/node to /home/local-admin/.vaadin/node/node
[INFO] Extracting NPM
[INFO] Local node installation successful.
[WARNING] Error checking if npm is new enough
com.vaadin.flow.server.frontend.FrontendUtils$UnknownVersionException: Unable to detect version of npm. Using command /home/local-admin/.vaadin/node/node --no-update-notifier --no-audit --version
    at com.vaadin.flow.server.frontend.FrontendUtils.getVersion (FrontendUtils.java:886)

BTW: The current Node LTS is 12.18.3

@RalfNaujokat
Copy link
Author

Same error on flow-maven-plugin

@Legioth Legioth transferred this issue from vaadin/maven-plugin Sep 11, 2020
@caalador
Copy link
Contributor

Hi.

Which version is this with?
Also can you see if the stack trace would define the FrontendTools row that calls FrontendUtils.getVersion()

The automatically installed node version will change to 12.18.3 in the next release versions.

@RalfNaujokat
Copy link
Author

HI.

I have used Vaadin 17.0.0 with the vaadin-maven-plugin 17.0.0
and vaadin 17.0.1 with the flow-maven-plugin 4.0.1

The complete log and stack trace is:

[INFO] --- flow-maven-plugin:4.0.1:prepare-frontend (default) @ appointments ---
[INFO] Couldn't find npm. Installing Node and NPM to /home/local-admin/.vaadin.
[INFO] Installing node version v12.16.0
[INFO] Downloading https://nodejs.org/dist/v12.16.0/node-v12.16.0-linux-x64.tar.gz to /home/local-admin/.vaadin/node-v12.16.0-linux-x64.tar.gz
[INFO] No proxies configured
[INFO] No proxy was configured, downloading directly
[INFO] Unpacking /home/local-admin/.vaadin/node-v12.16.0-linux-x64.tar.gz into /home/local-admin/.vaadin/node/tmp
[INFO] Copying node binary from /home/local-admin/.vaadin/node/tmp/node-v12.16.0-linux-x64/bin/node to /home/local-admin/.vaadin/node/node
[INFO] Extracting NPM
[INFO] Local node installation successful.
[WARNING] Error checking if npm is new enough
com.vaadin.flow.server.frontend.FrontendUtils$UnknownVersionException: Unable to detect version of npm. Using command /home/local-admin/.vaadin/node/node --no-update-notifier --no-audit --version
    at com.vaadin.flow.server.frontend.FrontendUtils.getVersion (FrontendUtils.java:886)
    at com.vaadin.flow.server.frontend.FrontendTools.validateNodeAndNpmVersion (FrontendTools.java:312)
    at com.vaadin.flow.plugin.maven.PrepareFrontendMojo.execute (PrepareFrontendMojo.java:111)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

@caalador
Copy link
Contributor

That is strange as the flags are the expected ones for npm as also the FrontendTools line is from the npm part for 4.0 (for 5.0 it would be node version check).

Which linux distro and java sdk are you running?
Also does this happen with the 14.3 release?

@RalfNaujokat
Copy link
Author

Hi,

i am using Oracle JDK 14.0.2 on Ubuntu 20.04.
I tried Vaadin 14.3.5 with the vaadin-maven-plugin,
but it's just the same:

[INFO] --- vaadin-maven-plugin:14.3.5:prepare-frontend (default) @ main ---
[INFO] Couldn't find npm. Installing Node and NPM to /home/local-admin/.vaadin.
[INFO] Installing node version v12.16.0
[INFO] Downloading https://nodejs.org/dist/v12.16.0/node-v12.16.0-linux-x64.tar.gz to /home/local-admin/.vaadin/node-v12.16.0-linux-x64.tar.gz
[INFO] No proxies configured
[INFO] No proxy was configured, downloading directly
[INFO] Unpacking /home/local-admin/.vaadin/node-v12.16.0-linux-x64.tar.gz into /home/local-admin/.vaadin/node/tmp
[INFO] Copying node binary from /home/local-admin/.vaadin/node/tmp/node-v12.16.0-linux-x64/bin/node to /home/local-admin/.vaadin/node/node
[INFO] Extracting NPM
[INFO] Local node installation successful.
[WARNING] Error checking if npm is new enough
com.vaadin.flow.server.frontend.FrontendUtils$UnknownVersionException: Unable to detect version of npm. Using command /home/local-admin/.vaadin/node/node --no-update-notifier --no-audit --version
    at com.vaadin.flow.server.frontend.FrontendUtils.getVersion (FrontendUtils.java:778)
    at com.vaadin.flow.server.frontend.FrontendTools.validateNodeAndNpmVersion (FrontendTools.java:313)
    at com.vaadin.flow.plugin.maven.PrepareFrontendMojo.execute (PrepareFrontendMojo.java:153)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)

@RalfNaujokat
Copy link
Author

Dird you notice that line: (Line feed inserted manually)

com.vaadin.flow.server.frontend.FrontendUtils$UnknownVersionException: Unable to detect version of npm. 
Using command /home/local-admin/.vaadin/node/node --no-update-notifier --no-audit --version

That simply does not work.
Executing that command directly in bash shows why:

pc05:~$ /home/local-admin/.vaadin/node/node --no-update-notifier --no-audit --version
/home/local-admin/.vaadin/node/node: bad option: --no-update-notifier
/home/local-admin/.vaadin/node/node: bad option: --no-audit
pc05:~$ 

This works:

pc05:~$ /home/local-admin/.vaadin/node/node --version
v12.16.0
pc05:~$ 

But is using node to get the version of npm the right way?

@caalador
Copy link
Contributor

I guess the command should contain node/node_modules/npm/bin/npm-cli.js after node, but for some reason it doesn't which is also strange as then I don't think it should contain node either as the check for script is that if script exists add node + script to command.

@joheriks
Copy link
Contributor

joheriks commented Sep 15, 2020

I can't reproduce this on Ubuntu 20.04 using Oracle JDK 14 and skeleton-starter. One possibility is that the canRead check at this line goes wrong. Based on the code logic the symptoms should then be missing the node/node_modules/npm/bin/npm-cli.js from the node command and the command-line parameters (--no-update-notifier and so on) erroneously going directly to the node executable.
@RalfNaujokat Can you check the permissions on the file ~/.vaadin/node/node_modules/npm/bin/npm-cli.js?

@RalfNaujokat
Copy link
Author

Should be readable, but not executable...

local-admin@pc05:~/.vaadin/node/node_modules/npm/bin$ ll ~/.vaadin/node/node_modules/npm/bin/
total 40K
drwxrwxr-x 3 local-admin local-admin 4,0K Sep 15 09:21 .
drwxrwxr-x 9 local-admin local-admin 4,0K Sep 15 09:21 ..
drwxrwxr-x 2 local-admin local-admin 4,0K Sep 15 09:21 node-gyp-bin
-rwxrw-r-- 1 local-admin local-admin  893 Sep 15 09:21 npm
-rw-rw-r-- 1 local-admin local-admin 4,6K Sep 15 09:21 npm-cli.js
-rwxrw-r-- 1 local-admin local-admin  464 Sep 15 09:21 npm.cmd
-rw-rw-r-- 1 local-admin local-admin  887 Sep 15 09:21 npx
-rw-rw-r-- 1 local-admin local-admin  177 Sep 15 09:21 npx-cli.js
-rw-rw-r-- 1 local-admin local-admin  519 Sep 15 09:21 npx.cmd
local-admin@pc05:~/.vaadin/node/node_modules/npm/bin$ 

@joheriks
Copy link
Contributor

The permissions look fine. However, I can't see any other possibility than that canRead for some reason returning false for ~/.vaadin/node/node_modules/npm/bin/npm-cli.js. Is there some security manager in place? Some project details or ideally a minimal reproducible example may be useful.

@RalfNaujokat
Copy link
Author

No security manager.
Perhaps the base dir in line 684 is wrong?
It must be ~/.vaadin at this time.

@HermanBovens
Copy link
Collaborator

A colleage also has this error, while I don't (for the same project), and one major difference is that I have Node (v10.13.0) locally installed, while in his case Vaadin downloads Node, as is also the case in this issue.

@taefi
Copy link
Contributor

taefi commented Dec 2, 2020

Hi @RalfNaujokat, is there a chance that you are using NVM to install and manage NodeJS on your machine? Anyway, could you please create a symbolic link to the Node executable in /usr/local/bin/?

@RalfNaujokat
Copy link
Author

Hi,
sorry for not looking at this a long time.

I am using Vaadin 18 right now, and it looks ok now.
I cleaned up ~/.vaadin/* and started a build on a project.
Output is:

[INFO] --- vaadin-maven-plugin:18.0.1:prepare-frontend (default) @ ui ---
[INFO] Couldn't find node. Installing Node and NPM to /home/local-admin/.vaadin.
[INFO] Installing node version v12.18.3
[INFO] Downloading https://nodejs.org/dist/v12.18.3/node-v12.18.3-linux-x64.tar.gz to /home/local-admin/.vaadin/node-v12.18.3-linux-x64.tar.gz
[INFO] No proxies configured
[INFO] No proxy was configured, downloading directly
[INFO] Unpacking /home/local-admin/.vaadin/node-v12.18.3-linux-x64.tar.gz into /home/local-admin/.vaadin/node/tmp
[INFO] Copying node binary from /home/local-admin/.vaadin/node/tmp/node-v12.18.3-linux-x64/bin/node to /home/local-admin/.vaadin/node/node
[INFO] Extracting NPM
[INFO] Local node installation successful.
[INFO] Added 21 default dependencies to main package.json

I can't see any version checking...

@RalfNaujokat
Copy link
Author

When i am using a local installation (node 15.3.0),
the download and installation of node v12.18.3 is skipped,
and only pnpm 4.4.0 is installed in ~/.vaadin/node_modules.
And again no visible version checking.

@RalfNaujokat
Copy link
Author

Meanwhile i am on JDK15.0.1 on Ubuntu 20.10

@taefi
Copy link
Contributor

taefi commented Dec 3, 2020

So basically that means the problem resolved by upgrading to V18 and all is good there, right?

@RalfNaujokat
Copy link
Author

Yes, as far as i can see, the problem is gone.

@tingyanshen
Copy link

Got the same error on Ubuntu 20.10 and Vaadin 19. Fixed by installing nodejs and npm.

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

No branches or pull requests

6 participants