Maven在目标目录中安装节点模块

时间:2017-10-04 10:52:18

标签: node.js maven npm

在我的pom.xml中,这是我的前端maven-plugin配置的样子。 我的package.json和gulpfiles位于项目的根目录中。

<plugin>        
<groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <!-- Use the latest released version: https://repo1.maven.org/maven2/com/github/eirslett/frontend-maven-plugin/ -->
                <version>1.6</version>
                <executions>
                    <execution>
                        <!-- optional: you don't really need execution ids, but it looks nice 
                            in your build log. -->
                        <id>install node and npm</id>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <!-- optional: default phase is "generate-resources" -->
                        <phase>generate-resources</phase>
                    </execution>

                    <execution>
                        <id>npm install</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>

                        <!-- optional: default phase is "generate-resources" -->
                        <phase>generate-resources</phase>

                        <configuration>
                            <!-- optional: The default argument is actually "install", so unless 
                                you need to run some other npm command, you can remove this whole <configuration> 
                                section. -->
                            <arguments>install ./target/node_modules</arguments>

                        </configuration>
                    </execution>

                    <execution>
                        <id>gulp</id>
                        <goals>
                            <goal>gulp</goal>
                        </goals>
                        <configuration>
                            <arguments>replace-runner-start</arguments>
                        </configuration>
                    </execution>

                    <execution>
                        <id>javascript tests</id>
                        <goals>
                            <goal>karma</goal>
                        </goals>

                        <!-- optional: the default plase is "test". Some developers choose 
                            to run karma in the "integration-test" phase. -->
                        <phase>test</phase>

                        <configuration>
                            <!-- optional: the default is "karma.conf.js" in your working directory -->
                            <karmaConfPath>src/main/karma_webapp_all_conf.js</karmaConfPath>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <!-- <workingDirectory>src/main</workingDirectory> -->
                    <installDirectory>target</installDirectory>
                    <nodeVersion>v6.11.3</nodeVersion>
                </configuration>
            </plugin>

当我像这样运行mvn clean install时,我在目标中安装了节点但是由于该文件夹不存在而无法安装node_modules。有没有办法在没有其他插件的情况下制作目录并在那里安装node_modules。

2 个答案:

答案 0 :(得分:0)

看起来node_modules路径错误。检查node_modules的路径。这可以通过

来完成

全球图书馆

您可以运行npm list -g来查看全局库的安装位置。

在Unix系统上,全局安装时,它们通常位于/usr/local/lib/node/usr/local/lib/node_modules。如果将NODE_PATH环境变量设置为此路径,则可以通过节点找到模块。

Windows XP - %USERPROFILE%\Application Data\npm\node_modules Windows 7,8和10 - %AppData%\npm\node_modules

非全球图书馆

非全局库安装在您当前所在文件夹中的node_modules子文件夹中。

您可以run npm list查看当前位置的已安装非全局库。

答案 1 :(得分:0)

如果仍然存在此问题,我建议您使用以下选项:

相关问题