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.24k stars 871 forks source link

npm link <package-name> throws exception when running via frontend-maven-plugin, manually it does work #1048

Open Vortilion opened 2 years ago

Vortilion commented 2 years ago

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

What is the current behavior? Running npm link my-awesome-custom-package to install a previous linked package does not work if done via frontend-maven-plugin:

[INFO] Running 'npm link my-awesome-custom-package' in C:\GITROOT\users\username\projektname\frontend [INFO] npm ERR! code E404 [INFO] npm ERR! 404 Not Found - GET https://registry.npmjs.org/my-awesome-custom-package - Not found [INFO] npm ERR! 404 [INFO] npm ERR! 404 'my-awesome-custom-package@*' is not in this registry.

It DOES exist in my global packages as a linked package.

It does work however if I do it manually on the command line, so why doesn't it work when the plugin runs the same command in the same directory?

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

<execution>
    <id>npm link</id>
    <goals>
        <goal>npm</goal>
    </goals>
    <configuration>
        <arguments>link my-awesome-custom-package</arguments>
    </configuration>
</execution>

after npm install execution. Execute mvn install.

My complete plugin.config:

<plugin>
    <groupId>com.github.eirslett</groupId>
    <artifactId>frontend-maven-plugin</artifactId>
    <version>1.12.1</version>
    <configuration>
        <workingDirectory>./</workingDirectory>
        <nodeVersion>v16.15.0</nodeVersion>
        <npmVersion>8.18.0</npmVersion>
    </configuration>
    <executions>
        <execution>
            <id>install node and npm</id>
            <goals>
                <goal>install-node-and-npm</goal>
            </goals>
        </execution>
        <execution>
            <id>npm install</id>
            <goals>
                <goal>npm</goal>
            </goals>
        </execution>
        <execution>
            <id>npm link</id>
            <goals>
                <goal>npm</goal>
            </goals>
            <configuration>
                <arguments>link my-awesome-custom-package</arguments>
            </configuration>
        </execution>
        <execution>
            <id>npm run build</id>
            <goals>
                <goal>npm</goal>
            </goals>
            <configuration>
                <arguments>run build</arguments>
            </configuration>
        </execution>
    </executions>
</plugin>

What is the expected behavior? Custom package is being added to node_modules folder, like it is when running command manually on terminal in the same folder.

Please mention your frontend-maven-plugin and operating system version. 1.12.1, Windows 10