jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.54k stars 4.02k forks source link

mvnw execution: failure of unpacking npm-6.9.0.tar.gz while running frontend-maven-plugin:install-node-and-npm on Win10 #9545

Closed shekvl closed 5 years ago

shekvl commented 5 years ago
Overview of the issue

While running mvnw, the following error is thrown while installing frontend-maven-plugin. I tried installing npm 6.9.0 first, but it did not make a difference: the installer still attempts to download and unpack it, leading to error. The system is quite clean: java, maven, and node were installed there for the first time prior to installing jhipster.

[INFO] --- properties-maven-plugin:1.0.0:read-project-properties (default) @ catalogue --- [INFO] [INFO] --- frontend-maven-plugin:1.7.5:install-node-and-npm (install node and npm) @ catalogue --- [INFO] Node v10.15.3 is already installed. [INFO] Installing npm version 6.9.0 [INFO] Unpacking C:\Users\vladimir.m2\repository\com\github\eirslett\npm\6.9.0\npm-6.9.0.tar.gz into c:\projects\catalog-v3-2a\node\node_modules [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.533 s [INFO] Finished at: 2019-04-09T14:02:52+02:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.7.5:install-node-and-npm (install node and npm) on project catalogue: Could not extract the npm archive: Could not extract archive: 'C:\Users\vladimir.m2\repository\com\github\eirslett\npm\6.9.0\npm-6.9.0.tar.gz': Expanding package/package.json would create file outside of c:\projects\catalog-v3-2a\node\node_modules -> [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

Motivation for or Use Case

I cannot go past this step while running mvnw, it does not depend if npm 6.9.0 is installed

Reproduce the error

install jhipster create a project from the below .yo-rc.json run mvnw

JHipster Version(s)

6.0.0-beta.0

JHipster configuration

INFO! Using JHipster version installed locally in current project's node_modules INFO! Executing jhipster:info INFO! Options: from-cli: true Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
catalogue@0.0.0 c:\projects\catalog-v3-2a
`-- generator-jhipster@6.0.0-beta.0
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "org.bbmri.catalogue",
      "nativeLanguage": "en"
    },
    "jhipsterVersion": "6.0.0-beta.0",
    "applicationType": "monolith",
    "baseName": "catalogue",
    "packageName": "org.bbmri.catalogue",
    "packageFolder": "org/bbmri/catalogue",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "postgresql",
    "prodDatabaseType": "postgresql",
    "searchEngine": "elasticsearch",
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "maven",
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "bXktc2VjcmV0LXRva2VuLXRvLWNoYW5nZS1pbi1wcm9kdWN0aW9uLWFuZC10by1rZWVwLWluLWEtc2VjdXJlLXBsYWNl",
    "clientFramework": "angularX",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "useSass": true,
    "clientPackageManager": "npm",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [],
    "enableTranslation": true,
    "nativeLanguage": "en",
    "languages": ["en", "de"]
  }
}

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions

Environment and Tools

java version "1.8.0_202" Java(TM) SE Runtime Environment (build 1.8.0_202-b08) Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)

git version 2.21.0.windows.1

node: v10.15.3

npm: 6.9.0

INFO! Congratulations, JHipster execution is complete!

Browsers and Operating System

Windows 10 v.1809, OS Build: 17763.79

shekvl commented 5 years ago

digging deeper revealed the following: 1) frontend-maven-plugin expects node to be installed under project-name/node and npm - under project-name/node/node_modules/npm (with a binary under its bin subdirectory), it does not understand that e.g npm was installed via npm (as in this case its binary goes to project-name/node_modules/.bin) 2) it can extract node.exe to its necessary location, and subsequently can find it there and skip further install attempts 3) due to the above error, it cannot unpack npm-6.9.0.tar.gz from the maven repository to its necessary location, so it subsequently cannot find npm there and attempts to install it on every run 4) npm-6.9.0.tar.gz contains npm installation under package, and not npm (i.e. it contains package/bin, package/lib etc, not npm/bin, npm/lib), so in any case it cannot be extracted properly from there without additional effort. I tried to create my own version of npm-6.9.0.tar.gz with npm/{lib,bin,...} inside and put it into the place in .m2\repository to check if the unpacking error is due to this problem, but it did not make a difference.

So I was able to go past this error by creating local node by hand i.e. by:

  1. making sure node.exe is in project-name/node (in my case, it was put there by previous failed runs of install-node-and-npm goal)
  2. creating project-name/node/node_modules/npm
  3. extracting sub-directories of package from npm-6.9.0.tar.gz there creating npm/bin, npm/lib etc

After that frontend-maven-plugin was able to find the local node and npm and proceed further:

[INFO] --- frontend-maven-plugin:1.7.5:install-node-and-npm (install node and npm) @ catalogue --- [INFO] Node v10.15.3 is already installed. [INFO] NPM 6.9.0 is already installed. [INFO] [INFO] --- frontend-maven-plugin:1.7.5:npm (npm install) @ catalogue --- [INFO] Running 'npm install' in c:\projects\catalog-v3-2a

Still, it is definitely not the right way of dealing with this.

pascalgrimaud commented 5 years ago

It looks like an environment problem with your machine, and not related to the generated code, provided by JHipster. Can you test our Devbox: https://github.com/jhipster/jhipster-devbox ?

shekvl commented 5 years ago

I tested this on two different computers, both running Windows, with exactly the same result. One of them had a freshly installed system, starting from OS (i.e. nothing except things necessary to run jhipster). I will definitely try Devbox and report the results.

pascalgrimaud commented 5 years ago

I installed Windows 10, in a VM and tested your config. Everything works fine. I don't have problem to download node and npm locally, so it definitely comes from your installation:

I'm closing this, as I can't reproduce. See my screenshot.

Capture d’écran de 2019-04-22 22-44-43

fortisstar-test commented 5 years ago

jhipster_mvnw_error

This issue occurs on my machine, running windows 10. I have deleted the folder C:\Users\fts00193.m2\repository\com\github\eirslett, and re-run mvnw, the error still occurs.

I already have existing npm and node version installed globally as shown below:

existing_node_npm_version

I use JHipster 6.0.0 and generate the sample application using https://start.jhipster.tech, extract the zip file into C:\Projects folder and execute mvnw.

Need to re-open this issue.

fortisstar-test commented 5 years ago

digging deeper revealed the following:

  1. frontend-maven-plugin expects node to be installed under project-name/node and npm - under project-name/node/node_modules/npm (with a binary under its bin subdirectory), it does not understand that e.g npm was installed via npm (as in this case its binary goes to project-name/node_modules/.bin)
  2. it can extract node.exe to its necessary location, and subsequently can find it there and skip further install attempts
  3. due to the above error, it cannot unpack npm-6.9.0.tar.gz from the maven repository to its necessary location, so it subsequently cannot find npm there and attempts to install it on every run
  4. npm-6.9.0.tar.gz contains npm installation under package, and not npm (i.e. it contains package/bin, package/lib etc, not npm/bin, npm/lib), so in any case it cannot be extracted properly from there without additional effort. I tried to create my own version of npm-6.9.0.tar.gz with npm/{lib,bin,...} inside and put it into the place in .m2\repository to check if the unpacking error is due to this problem, but it did not make a difference.

So I was able to go past this error by creating local node by hand i.e. by:

  1. making sure node.exe is in project-name/node (in my case, it was put there by previous failed runs of install-node-and-npm goal)
  2. creating project-name/node/node_modules/npm
  3. extracting sub-directories of package from npm-6.9.0.tar.gz there creating npm/bin, npm/lib etc

After that frontend-maven-plugin was able to find the local node and npm and proceed further:

[INFO] --- frontend-maven-plugin:1.7.5:install-node-and-npm (install node and npm) @ catalogue --- [INFO] Node v10.15.3 is already installed. [INFO] NPM 6.9.0 is already installed. [INFO] [INFO] --- frontend-maven-plugin:1.7.5:npm (npm install) @ catalogue --- [INFO] Running 'npm install' in c:\projects\catalog-v3-2a

Still, it is definitely not the right way of dealing with this.

This manual extraction solve the issue. jhipster should be fixed to ensure smooth project build.

pascalgrimaud commented 5 years ago

@fortisstar-test : as you can see in my previous comment, I installed a VM with Windows 10 and didn't manage to reproduce. Without additionnal information, it's impossible to help you. As I can't reproduce with Linux, VM with Windows10, it comes from your environment and your installation. You can have a look directly to the project frontend-maven-plugin too

Not sure we can do something on our side as it is managed by frontend-maven-plugin

Could you try our DevBox: https://github.com/jhipster/jhipster-devbox ?

Gkodkod commented 5 years ago

Had the same issue & solved it quickly running it all in intellij IDEA Ultimate (as opposed to command line)

hackpros commented 5 years ago
  1. use administrator run cmd.exe
  2. run mvn install or other...
daniels75 commented 5 years ago

Hi,

I have the same problem - yesterday I've create a new applicaiton with jhipster v. 6.4.1 on Windows 10. I guess I've found where is the problem. It is due to plugin: frontend-maven-plugin.version in version 1.8.0 and previous. I've just debugged such a plugin and I found the problem is in the DefaultArchiveExtractor.extract method in the plugin. Here is an output from plugin with some logs that I've added: [INFO] Node v10.16.3 is already installed. [INFO] Installing npm version 6.11.3 [INFO] Unpacking C:\Users\daniels.m2\repository\com\github\eirslett\npm\6.11.3\npm-6.11.3.tar.gz into c:\daniels\sources\frontend-maven-plugin-master\example-project\node\node_modules [INFO] ====> tarEntry.getName(): package/node_modules/define-properties/.editorconfig [INFO] ====> canonicalDestinationDirectory: C:\daniels\sources\frontend-maven-plugin-master\example-project\node\node_modules [INFO] ====> destinationDirectory: c:\daniels\sources\frontend-maven-plugin-master\example-project\node\node_modules [INFO] ====> destPath.getCanonicalPath(): C:\daniels\sources\frontend-maven-plugin-master\example-project\node\node_modules\package\node_modules\define-properties.editorconfig

The problem is that plugin is trying to compare: if (!destPath.getCanonicalPath().startsWith(destinationDirectory)) and if it does not much then that error is showed.

Here: path destPath.getCanonicalPath() starts with: C: but path: destinationDirectory starts with: c:

Anyway it looks like that the problem has been already fixed in the last SNAPSHOT - please see: https://github.com/eirslett/frontend-maven-plugin/commit/6175368cca93620bad45260152391b360d0751db

but there is no new released version of that plugin.

One of the option to fix it is:

  1. copy a files extracted from .m2\repository\com\github\eirslett\npm\6.11.3\npm-6.11.3.tar.gz\package to

    \node\node_modules\npm\ So finally: \node\ contains node.exe \node\node_modules\npm\ contains everthing what was in the npm-6.11.3.tar.gz\\package
  2. Download a latest version of the frontend-maven-plugin. Run: mvn clean install and the just use this version (SNAPSHOT) in the jhipster pom.xml file like follows:

    1.8.1-SNAPSHOT