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

npx not in PATH when running as part of npm goal #1002

Closed eidottermihi closed 2 years ago

eidottermihi commented 2 years ago

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

Trying to build a project with a package.json that uses npm-force-resolutions via npx in preinstall:

{
  "name": "blabla",
  "scripts": {
    "preinstall": "npm install --package-lock-only --ignore-scripts && npx npm-force-resolutions",
   }
}

using the following Maven configuration:

<plugin>
    <groupId>com.github.eirslett</groupId>
    <artifactId>frontend-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>install-node-and-npm</goal>
            </goals>
        </execution>
                <execution>
            <id>npm-install</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>npm</goal>
            </goals>
            <configuration>
                <arguments>install</arguments>
            </configuration>
        </execution>
    </executions>
</plugin>

fails when running in a GitLab CI build using official docker image maven:3-jdk-11

[INFO] --- frontend-maven-plugin:1.12.0:install-node-and-npm (install node and npm) @ myproject ---
[INFO] Installing node version v14.16.0
[ ..... ]
[INFO] Extracting NPM
[INFO] Installed node locally.
[INFO] 
[INFO] --- frontend-maven-plugin:1.12.0:npm (npm-install) @ myproject  ---
[INFO] Running 'npm install' in /builds/fsQupcmA/0/group/project/repo/module
[INFO] 
[INFO] > mypackage@0.1.0 preinstall /builds/fsQupcmA/0/group/project/repo/module
[INFO] > npx npm-force-resolutions
[INFO] 
[INFO] sh: 1: npx: not found
[INFO] npm ERR! code ELIFECYCLE
[INFO] npm ERR! syscall spawn
[INFO] npm ERR! file sh
[INFO] npm ERR! errno ENOENT

If the current behavior is a bug, please provide the steps to reproduce.

Use a package.json that has a preinstall script that uses npx.

What is the expected behavior?

IMO npx should be on the PATH when npm goal is executed.

Please mention your frontend-maven-plugin and operating system version.

frontend-maven-plugin: 1.12.0 OS: Linux x64 / Docker Image maven:3-jdk-11 (https://hub.docker.com/_/maven)