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.23k stars 867 forks source link

installing node and npm execution does not respect .npmrc registry setting #906

Closed ajkimoto closed 3 years ago

ajkimoto commented 4 years ago

I have tried using .npmrc to set the npm registry, but is ignored by the install node and npm execution. However, If I change the nodeVersion and npmVersion in that step to to provided (to prevent the attempted npm/node downloads), the setting in .npmrc is respected by the subsequent npm install execution. I have seen this same behavior now in completely different projects.

I have tried placing .npmrc is in the parent directory of the pom.xml and also in the same directory as the pom.xml

Configuration is like this:

<plugin>
    <groupId>com.github.eirslett</groupId>
    <artifactId>frontend-maven-plugin</artifactId>
    <version>1.7.6</version>
    <configuration>
        <nodeVersion>v10.13.0</nodeVersion>
        <npmVersion>6.9.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>
    </executions>
</plugin>

Watching the build, I can see it attempting to download (for example) npm from:

https://registry.npmjs.org/npm/-/npm-6.9.0.tgz

Instead of our internal mirror as defined in .npmrc.

Any suggestions?

eirslett commented 4 years ago

By default, the plugin will download node and npm via the proxy you have configured in your Maven settings: https://github.com/eirslett/frontend-maven-plugin#proxy-settings

jblayneyXpanxion commented 3 years ago

@eirslett - thanks for the link - so you're saying that disabling npm's inheritance of the proxy settings from maven will make it respect the .npmrc file? Otherwise I'm failing to see the connection to the author's issue with the npmrc file to the proxy configs you've linked to... could you please explicitly state whatever point or inferences you were hoping to communicate by posting the link above as it relates to the author's problem?

eirslett commented 3 years ago

I believe disabling the inheritance stuff will make it respect npmrc. I don't use any proxies myself, so I can't say for sure. Do you have a similar problem?

thejeff77 commented 3 years ago

Disabling the proxy has not helped me solve the same issue. In my case the npmrc is in home dir (~/.npmrc), and the same directory of the pom.xml, and in the parent directory. It still doesn't seem to be respecting the npmrc file.

Is there a better place to put the npmrc? Perhaps a config could be added for it.

    <plugins>

        <plugin>
            <groupId>com.github.eirslett</groupId>
            <artifactId>frontend-maven-plugin</artifactId>
            <version>1.10.4</version>
            <configuration>
                <!-- nodeVersion>provided</nodeVersion> <npmVersion>provided</npmVersion -->
                <nodeVersion>v14.8.0</nodeVersion>
                <npmVersion>6.14.7</npmVersion>
                <workingDirectory>./</workingDirectory>
                <configuration>
                    <npmInheritsProxyConfigFromMaven>false</npmInheritsProxyConfigFromMaven>
                </configuration>
            </configuration>
            <executions>
                <execution>
                    <id>install-node-and-npm</id>
                    <goals>
                        <goal>install-node-and-npm</goal>
                    </goals>
                </execution>
                <execution>
                    <id>npm-run-build</id>
                    <goals>
                        <goal>npm</goal>
                    </goals>
                    <configuration>
                        <arguments>run custom-build-step</arguments>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
eirslett commented 3 years ago

Why do you have <configuration> inside <configuration>?

ajkimoto commented 3 years ago

I am embarrassed. It turns out that I needed to add the correct value in the <npmDownloadRoot> tag. All is well now.