Maven项目构建失败求助:com.github.eirslett:frontend-maven-plugin:0.0.27:npm报错
解决
com.github.eirslett:frontend-maven-plugin:0.0.27:npm构建失败的思路 优先升级插件版本:0.0.27是2015年的老旧版本,存在大量兼容性问题,直接替换为最新稳定版(如1.15.0)能解决绝大多数遗留问题。修改pom.xml中的插件配置:
<plugin> <groupId>com.github.eirslett</groupId> <artifactId>frontend-maven-plugin</artifactId> <version>1.15.0</version> <!-- 保留原有执行目标与其他配置 --> </plugin>排查网络与镜像配置:插件需下载npm包,若网络受限或默认镜像访问失败,可指定国内镜像加速:
<plugin> <groupId>com.github.eirslett</groupId> <artifactId>frontend-maven-plugin</artifactId> <version>1.15.0</version> <configuration> <npmRegistryUrl>https://registry.npmmirror.com/</npmRegistryUrl> </configuration> </plugin>同时检查Maven的settings.xml代理配置是否正确,避免代理拦截下载请求。
手动指定Node.js版本:旧插件自动下载的Node.js版本可能与系统不兼容,强制指定适配版本:
<plugin> <groupId>com.github.eirslett</groupId> <artifactId>frontend-maven-plugin</artifactId> <version>1.15.0</version> <executions> <execution> <id>install-node-npm</id> <goals> <goal>install-node-and-npm</goal> </goals> <configuration> <nodeVersion>v18.17.0</nodeVersion> <npmVersion>9.6.7</npmVersion> </configuration> </execution> <!-- 其他执行目标 --> </executions> </plugin>清理前端缓存:除了Maven的m2仓库,还需清理npm本地缓存:
npm cache clean --force同时删除项目根目录下的
node_modules文件夹和package-lock.json文件,让插件重新安装依赖。检查系统权限:确保运行Maven的用户拥有足够权限,能写入本地仓库、项目目录等路径,避免因权限不足导致下载或安装失败。
内容的提问来源于stack exchange,提问作者alex nascimento
相关产品推荐
相关产品推荐

