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

NPM fails to install on windows cmd #19225

Closed crowne closed 2 years ago

crowne commented 2 years ago
Overview of the issue

I'm trying to build the sample jdls on windows command line using the latest version of jhipster main branch (>7.8.1) the build generates all of the files but then throws the following error during the build:

npm WARN deprecated istanbul@0.4.5: This module is no longer maintained, try this instead: npm WARN deprecated npm i nyc npm WARN deprecated Visit https://istanbul.js.org/integrations for other alternatives. npm WARN deprecated puppeteer@9.1.1: Version no longer supported. Upgrade to @latest npm ERR! code 127 npm ERR! path C:\github\jhmfe\21-points\node_modules\puppeteer npm ERR! command failed npm ERR! command bash -c node install.js npm ERR! /bin/bash: node: command not found

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\user.name\AppData\Local\npm-cache_logs\2022-07-25T13_51_58_582Z-debug.log Error executing './npmw install', execute it yourself. (Command failed with exit code 127: ./npmw install)

Motivation for or Use Case

The sample jdls should be buildable without error. I also tried the reactive-mf.jdl

Reproduce the error

git clone https://github.com/jhipster/generator-jhipster.git npm link npm ci

cd .. mkdir 21-points cd 21-points curl.exe -o 21-points.jh https://raw.githubusercontent.com/jhipster/jdl-samples/main/21-points.jh jhipster jdl 21-points.jh

Related issues
Suggest a Fix
JHipster Version(s)

main branch

JHipster configuration

jdl = https://raw.githubusercontent.com/jhipster/jdl-samples/main/21-points.jh

Entity configuration(s) entityName.json files generated in the .jhipster directory
Browsers and Operating System

windows 10

OmarHawk commented 2 years ago

Well, then it is not only me:

https://github.com/jhipster/generator-jhipster/pull/18936#issuecomment-1167677136

@mshima - guess this will break a few people's local environment...

mshima commented 2 years ago

@OmarHawk I don’t think it’s related. Removing puppeteer should workaround this one.

In any case you should open an issue to track that behavior and if we should revert. It was the best way I found to make npm scripts work on GitHub actions.

OmarHawk commented 2 years ago

I think it is, @mshima - The problem is not puppeteer, but that it tries to execute a failing command during installation:

npm ERR! code 127 npm ERR! path C:\github\jhmfe\21-points\node_modules\puppeteer npm ERR! command failed npm ERR! command bash -c node install.js

Which is because with the above mentioned Pull Request, we do write an .npmrc locally into the project folder forcing bash as a commandline.

mshima commented 2 years ago

@OmarHawk ok, your log was missing that part, if it matches. We provide node installed though maven/gradle. It’s possible to add the node PATH at npmw.

Something like.

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
PATH=$SCRIPT_DIR/target/node/:$PATH
export PATH
OmarHawk commented 2 years ago

well, the problem is not that node is not installed with maven/gradle, but that the commandline configured is not able to find the installed node, as in my case, the "bash" command is executed as wsl command, where there is no reference to the PATH where node is on.

Maybe @crowne can give your suggestion a try, don't know if I'll get to it this week.

ettolo commented 1 year ago

Hi, i have the same problem with Jhipster RC 8.0.1, monolithic application with React I solved deleting directories

running jhipster again and it worked