首页 > 解决方案 > 无法执行目标 com.github.eirslett:frontend-maven-plugin:1.7.5:npm (angularcli build dev) 无法运行任务:'npm run build' 失败

问题描述

我有一个使用 java 和 angular 作为前端的 Web 应用程序

几天前,我从 ng5 迁移到 ng7 并开始使用 npm 而不是 yarn 包管理器。在迁移之前一切都很好,但是之后当我运行时,spring-boot:run goal我得到了下面的错误

Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.7.5:npm (angularcli build dev) on project ... : Failed to run task: 'npm run build' failed

在这个错误之前,我得到一个关于角度的错误,上面写着

no such file or directory, open '/Users/nariman/Documents/IdeaProject/yadaki/node_modules/jquery/dist/jquery.min.js'

我在我的 package.json 中添加了 jquery 依赖项,但是当我搜索 node_module 包时,有时我无法理解某些内容我有 JQuery 文件夹(带有 Capital Q),其中没有 dist 文件夹(因此应用程序构建失败),有时有一个 jquery 文件夹(带有普通 q),它有一个 dist 文件夹并且应用程序完全构建

我使用前端 Maven 插件

pom.xml

<plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>1.7.5</version>
                <executions>
                    <execution>
                        <id>install node and npm</id>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>${node.version}</nodeVersion>
                            <npmVersion>${npm.version}</npmVersion>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm install</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                    </execution>

                    <execution>
                        <id>angularcli build dev</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                            <arguments>run build</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

包.json

"jquery": "3.2.1", 

angular-version : 7.2.4 node-version : 10.15.3 npm-version : 6.9.0

标签: jqueryspring-bootnpmangular-climaven-frontend-plugin

解决方案


推荐阅读