Maven中maven-front-plugin执行npm install因证书缺失失败
Maven Frontend Plugin执行npm install时证书验证失败
已完成操作
- 从同事处获取正确的
.crt格式证书,通过以下命令导入Java密钥库,Java应用可正常编译构建:
keytool -import -trustcacerts -alias <your_alias_name> -file <path_to_certificate_file> -keystore <JAVA_HOME>/lib/security/cacerts
问题现象
项目中配置的maven-front-plugin执行npm install目标失败,相关Maven配置如下:
<executions> <execution> <id>install-node-and-npm</id> <goals> <goal>install-node-and-npm</goal> </goals> </execution> <execution> <id>npm-install</id> <goals> <goal>npm</goal> </goals> </execution> <execution> <id>build-frontend</id> <goals> <goal>npm</goal> </goals> <phase>prepare-package</phase> <configuration> <arguments>run build:development</arguments> </configuration> </execution> </executions>
其中install-node-and-npm目标执行正常,但npm install目标报错:
[INFO] [1m--- [0;32mfrontend:1.9.1:npm[m [1m(npm-install)[m @ [36mapii[0;1m --- [INFO] Running 'npm install' in C:\Users\thomas.holmes\git\myapp-app\myapp\src\main\frontend [INFO] npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY [INFO] npm ERR! errno UNABLE_TO_GET_ISSUER_CERT_LOCALLY [INFO] npm ERR! request to https://registry.npmjs.org/zustand/-/zustand-4.5.5.tgz failed, reason: unable to get local issuer certificate
已尝试的无效方案
- 方案1:创建
.m2/settings.xml配置ssl-profile指定密钥库路径和密码,未生效(此为首选方案,不想全局生效) - 方案2:在命令行添加JVM参数执行
mvn clean install,或设置NODE_EXTRA_CA_CERTS环境变量,均出现相同的UNABLE_TO_GET_ISSUER_CERT_LOCALLY错误;设置环境变量时还提示无法加载密钥库文件
已大量搜索相关内容仍未解决,若需更多信息请告知。
内容的提问来源于stack exchange,提问作者tjholmes66
相关产品推荐
相关产品推荐

