[O]Flink版本适配改造(三)
# 背景说明
在编译 flink-runtime-web
模块时,Maven 会调用 frontend-maven-plugin 自动安装 Node.js 和 npm,并执行 npm install
等前端构建操作。但默认行为依赖国外源,极易导致下载失败或构建超时。
因此我们需调整 pom.xml
中插件配置,切换为国内镜像,并修改安装参数以增强稳定性。
# 一、设置国内 Node.js 与 npm 镜像源
我们首先修改 frontend-maven-plugin
插件的 install-node-and-npm
执行段,新增镜像地址配置。
原始写法:
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v16.13.2</nodeVersion>
<npmVersion>8.1.2</npmVersion>
</configuration>
</execution>
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
推荐写法:
<execution>
<id>install node and npm</id>
<phase>generate-resources</phase>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v16.13.2</nodeVersion>
<npmVersion>8.1.2</npmVersion>
<nodeDownloadRoot>https://cdn.npmmirror.com/binaries/node/</nodeDownloadRoot>
<npmDownloadRoot>https://registry.npmmirror.com/npm/-/</npmDownloadRoot>
</configuration>
</execution>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
新增了 <nodeDownloadRoot>
与 <npmDownloadRoot>
两个字段,注意 以使用阿里 NPM
镜像站,显著提升下载成功率。
# 二、修改 npm install 执行逻辑
我们还需替换 npm install
的默认参数,以规避 ci
模式下对 package-lock.json
的严格依赖,同时添加代理配置与日志调试参数。
原始写法:
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>ci --cache-max=0 --no-save ${npm.proxy}</arguments>
<environmentVariables>
<HUSKY_SKIP_INSTALL>true</HUSKY_SKIP_INSTALL>
</environmentVariables>
</configuration>
</execution>
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
推荐写法:
<execution>
<id>npm install</id>
<phase>process-resources</phase>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install --unsafe-perm --verbose --progress</arguments>
<npmRegistryURL>https://registry.npmmirror.com/</npmRegistryURL>
<environmentVariables>
<HUSKY_SKIP_INSTALL>true</HUSKY_SKIP_INSTALL>
<HOME>${project.build.directory}/.npmhome</HOME>
</environmentVariables>
</configuration>
</execution>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
- 01
- bigtop-select 打包缺 compat 报错修复 deb07-16
- 02
- bigtop-select 打包缺 control 文件报错修复 deb07-16
- 03
- 首次编译-环境初始化 必装07-16