frontend-maven-plugin插件无法下载nodejs和npm的问题

3 篇文章 0 订阅

npm clean package 报错:

[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.6:install-node-and-npm (install node and npm) on project XXX:
 Could not download Node.js: Could not download https://nodejs.org/dist/v9.11.1/node-v9.11.1-linux-x64.tar.gz:
  sun.security.validator.ValidatorException: PKIX path building failed: 
  sun.security.provider.certpath.SunCertPathBuilderException:
  unable to find valid certification path to requested target -> [Help 1]

 

修改 pom.xml文件中的frontend-maven-plugin插件配置:

<plugin>
        <groupId>com.github.eirslett</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
        <version>${frontend-maven-plugin.version}</version>
        <executions>
          <execution>
            <id>install node and npm</id>
            <goals>
              <goal>install-node-and-npm</goal>
            </goals>
            <configuration>
              <nodeDownloadRoot>http://nodejs.org/dist/</nodeDownloadRoot>
              <npmDownloadRoot>http://registry.npmjs.org/npm/-/</npmDownloadRoot>
              <nodeVersion>v9.11.1</nodeVersion>
            </configuration>
          </execution>
          <!-- Install all project dependencies -->
          <execution>
            <id>npm install</id>
            <goals>
              <goal>npm</goal>
            </goals>
            <!-- optional: default phase is "generate-resources" -->
            <phase>generate-resources</phase>
            <!-- Optional configuration which provides for running any npm command -->
            <configuration>
              <arguments>install</arguments>
            </configuration>
          </execution>
          <!-- Build and minify static files -->
          <execution>
            <id>npm run build</id>
            <goals>
              <goal>npm</goal>
            </goals>
            <configuration>
              <arguments>run build</arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>

添加了:

              <nodeDownloadRoot>http://nodejs.org/dist/</nodeDownloadRoot>
              <npmDownloadRoot>http://registry.npmjs.org/npm/-/</npmDownloadRoot>

如果您使用frontend-maven-plugin打包的jar文件中没有static文件夹,那可能是因为frontend-maven-plugin默认不会将静态资源文件包含在打包的jar文件中。为了解决这个问题,您可以尝试以下步骤: 1. 在您的Vue项目的根目录下创建一个名为`static`的文件夹,并将您的静态资源文件放置在其中。 2. 在您的Vue项目的根目录下创建一个名为`.npmrc`的文件,并添加以下内容: ``` prefix=${project.basedir}/target/${project.build.finalName}/static ``` 这将告诉frontend-maven-plugin将静态资源文件复制到打包的jar文件中的正确位置。 3. 更新您的pom.xml文件中frontend-maven-plugin插件的配置,确保它包含`copy`目标,并将`copy`目标的`outputDirectory`设置为`${project.build.directory}/${project.build.finalName}/static`。示例如下: ```xml <plugin> <groupId>com.github.eirslett</groupId> <artifactId>frontend-maven-plugin</artifactId> <version>1.12.0</version> <executions> <!-- 其他执行目标 --> <!-- ... --> <!-- 添加 copy 目标 --> <execution> <id>copy files</id> <goals> <goal>copy</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/${project.build.finalName}/static</outputDirectory> <resources> <resource> <directory>static</directory> <includes> <include>**/*</include> </includes> </resource> </resources> </configuration> </execution> </executions> </plugin> ``` 4. 重新运行`mvn clean install`命令来重新打包您的应用。这将确保静态资源文件被正确地复制到打包的jar文件中的static文件夹中。 现在,您应该能够在打包后的jar文件中找到static文件夹并包含您的静态资源文件。请确保在使用这些静态资源文件时,使用正确的路径引用它们。 希望这能解决您的问题!如有其他疑问,请随时追问。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值