当前位置: 首页 > 知识库问答 >
问题:

前端maven插件在运行npm run build时找不到包。json文件

尉迟华翰
2023-03-14

我正在用spring boot后端和angular前端构建一个应用程序。我正在使用前端maven插件在运行maven时构建前端当我运行mvn spring boot:run时我得到以下错误:

mvn spring-boot:run
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< com.demo:investmentswallet >------------------
[INFO] Building investmentswallet 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:2.2.6.RELEASE:run (default-cli) > test-compile @ investmentswallet >>>
[INFO]
[INFO] --- frontend-maven-plugin:1.9.1:install-node-and-npm (install-npm) @ investmentswallet ---
[INFO] Node v12.16.3 is already installed.
[INFO]
[INFO] --- frontend-maven-plugin:1.9.1:npm (npm-install) @ investmentswallet ---
[INFO] Running 'npm install' in C:\Users\Michal\Desktop\InvestmentsWallet
[INFO] npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\Michal\package.json'
[INFO] npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Michal\package.json'
[INFO] npm WARN @auth0/angular-jwt@2.0.0 requires a peer of @angular/common@^6.0.0 but none is installed. You must install peer dependencies yourself.
[INFO] npm WARN gatsby-plugin-react-helmet@3.1.7 requires a peer of gatsby@^2.0.0 but none is installed. You must install peer dependencies yourself.
[INFO] npm WARN react-helmet@5.2.1 requires a peer of react@>=15.0.0 but none is installed. You must install peer dependencies yourself.
[INFO] npm WARN react-side-effect@1.2.0 requires a peer of react@^0.13.0 || ^0.14.0 || ^15.0.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
[INFO] npm WARN Michal No description
[INFO] npm WARN Michal No repository field.
[INFO] npm WARN Michal No README data
[INFO] npm WARN Michal No license field.
[INFO]
[INFO] audited 73 packages in 0.853s
[INFO] found 1 low severity vulnerability
[INFO]   run `npm audit fix` to fix them, or `npm audit` for details
[INFO]
[INFO] --- frontend-maven-plugin:1.9.1:npm (npm run build) @ investmentswallet ---
[INFO] Running 'npm run build' in C:\Users\Michal\Desktop\InvestmentsWallet
[INFO] npm ERR! code ENOENT
[INFO] npm ERR! syscall open
[INFO] npm ERR! path C:\Users\Michal\package.json
[INFO] npm ERR! errno -4058
[INFO] npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\Michal\package.json'
[INFO] npm ERR! enoent This is related to npm not being able to find a file.
[INFO] npm ERR! enoent
[INFO]
[INFO] npm ERR! A complete log of this run can be found in:
[INFO] npm ERR!     C:\Users\Michal\AppData\Roaming\npm-cache\_logs\2020-05-24T13_11_03_257Z-debug.log
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.802 s
[INFO] Finished at: 2020-05-24T15:11:03+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.9.1:npm (npm run build) on project investmentswallet: Failed to run task: 'npm run build' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: -4058 (Exit value: -
4058) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

它似乎找不到package.json文件?为什么它在用户目录中寻找它?在客户文件夹里

这是我的pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.6.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.demo</groupId>
    <artifactId>investmentswallet</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>investmentswallet</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>5.3.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>1.9.1</version>
                <configuration>
                    <nodeVersion>v12.16.3</nodeVersion>
                </configuration>
                <executions>
                    <execution>
                        <id>install-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 run build</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>run build</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>target/classes/public</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>client/dist/client</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

以下是我的项目结构:

知道是怎么回事吗?

共有1个答案

锺离飞飙
2023-03-14

我发现解决这个问题的办法是,在前端maven插件配置中,必须指定workingDirectory和installDirectory。所以在我的例子中,pom中的插件定义。xml将如下所示:

<plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>1.9.1</version>
                <configuration>
                    <nodeVersion>v12.16.3</nodeVersion>
                    <workingDirectory>client</workingDirectory>
                    <installDirectory>target</installDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>install-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 run build</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>run build</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
 类似资料:
  • 这不是这个问题的重复。我在将外部依赖项包含到Javadoc中时遇到了问题,这不是问题所在。 我正在尝试将我的API部署到Maven Central。除了Maven Javadoc插件外,一切都很顺利。我的API有两个依赖项(Spigot API-org.spigotmc:Spigot API:1.19-R0.1-SNAPSHOT和JetBrains注释-org.JetBrains:Annotati

  • [错误]在当前项目和插件组[org.apache.maven.plugins,org.codehaus.mojo]中没有找到前缀'fortify'的插件[本地(C:\用户\. m2\存储库),中央(https://repo.maven.apache.org/maven2)]

  • cd project pnpm install Scope: all 8 workspace projects Lockfile is up to date, resolution step is skipped Already up to date . postinstall$ turbo run stub . postinstall: • Packages in scope: @vben/es

  • 遵循一些maven docker示例,产生了以下代码,运行mvn包dockerfile:build,但出现以下错误:[错误]在当前项目和插件组[org.apache.maven.plugins,org.codehaus.mojo]中找不到前缀为“dockerfile”的插件,这些插件组可从存储库获得。。。 请问我该从这里去哪里?

  • 我有一个程序,必须从终端界面播放声音。 代码相当简单,如下所示: 该文件位于“我的源路径”中的“音乐”文件夹中。 当我在eclipse中运行程序时,所有工作都非常好。但是如果我将其导出到. jar文件中并在windows cmd中尝试它,我会收到这条消息 [编辑]音频文件确实已打包到中。jar,但它仍然不起作用。 是否有可能播放来自windows提示符的声音?如果没有,是否有这样的声音? 谢谢Si

  • 问题内容: 因此,当我尝试从xcode终端构建代码时,它失败了,并给了我一个找不到“ Cordova / CDVViewController.h”文件的错误,但是当我从xcode进行构建时,它就可以了。 在我的Xcode中,我完成了整个Cordova子目录的事情Upgrade Cordova 。另外,当我运行列表。这是我在下面看到的: xcodebuild-列表 有关项目“ myProject”的