https://www.cnblogs.com/guangdelw/p/18763336
https://2048.csdn.net/682c1be8606a8318e857d687.html
最近公司新接了一个项目,要求是:需要再桌面云中进行内网开发,所有的开发桌面云没办法连接公网,但是内网搭建了nexus私服,java 和 npm 的应用可以通过nexus私服来下载依赖。
我们本地的文件可以复制到桌面云内部,但是桌面云中的文件无法复制出来。
目标:
代码迁移的过程就不描述了,这里着重描述安装Jenkins 和 添加配置。
以下是一些常用的国内 Jenkins 插件更新源地址:
由于公司的后端代码使用的JDK版本为1.8,所以为了统一jdk版本,所以最初选定使用JDK8的最后一个版本:Jenkins-2.346.3;
但是再实际操作的时候发现:Jenkins在线安装插件的时候,并不会将当前Jenkins的版本传过去获取适合当前版本的插件,而是会获取当前最新版本,基于这种情况最终选定安装比较LTS新版本的2.479.3 (注意这里使用的是JDK17)
而安装的过程区分为两种方式:
相比之下第一种操作方式更简单,所以最终选用第一种方式。
但是当前时间(2025-05-27)前后国内的插件源没办法使用,找不到对应的 update-center.json 文件,所以吭哧了好久最终使用魔法直接连接插件官网直接进行下载的。
操作步骤如下:
由于我们使用服务器为:Centos7.9,而项目依赖的nodejs版本要求为:16.15.1, pnpm的安装要求为:大于18,基于安装LTS版本的要求,最终选定安装:18.20.8或者20.19.2版本。
而官网提供 18.20.8 或者 20.19.2 版本的nodejs再Centos7.9通过tar包安装配置后,再执行:node -v 的过程出现类似一下的错误:
$ node -v
/lib64/libm.so.6: version `GLIBC_2.27' not found (required by ./node)
/lib64/libc.so.6: version `GLIBC_2.25' not found (required by ./node)
/lib64/libc.so.6: version `GLIBC_2.28' not found (required by ./node)
/lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by ./node)
/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by ./node)
/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./node)
linux-vdso.so.1 => (0x00007ffca6bd4000)
libdl.so.2 => /lib64/libdl.so.2 (0x00002b574ed87000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00002b574ef8b000)
libm.so.6 => /lib64/libm.so.6 (0x00002b574f293000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00002b574f595000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00002b574f7ab000)
libc.so.6 => /lib64/libc.so.6 (0x00002b574f9c7000)
/lib64/ld-linux-x86-64.so.2 (0x00002b574eb63000)
大概的原因是:
而CentOS 7.x等操作系统自带的glibc版本为2.17,Node.js v18.x或更高编译的环境所需glibc≥2.28,所以这里有三种方案:
再unofficial-builds提供的nodejs中, 18.20.8 版本再实际的使用过程中发现还是会有报错的情况,所以最终选择了 20.19.2,下载的地址为:
https://unofficial-builds.nodejs.org/download/release/v20.19.2/node-v20.19.2-linux-x64-glibc-217.tar.xz
具体的操作如下:
tar -Jxf node-v20.19.2-linux-x64-glibc-217.tar.xz
对文件进行解压缩. /etc/profile
npm config set registry https://nexus.sunwoda.com/repository/npm-group
{
// 省略部分配置
"devDependencies": {
"@ant-design/colors": "^6.0.0",
"@commitlint/cli": "^17.6.6",
"@commitlint/config-conventional": "^17.6.6",
"@iconify/json": "^2.2.87",
"@purge-icons/generated": "^0.9.0",
"@types/codemirror": "^5.60.8",
"@types/crypto-js": "^4.1.1",
"@types/intro.js": "^5.1.1",
"@types/lodash-es": "^4.17.7",
"@types/mockjs": "^1.0.7",
"@types/nprogress": "^0.2.0",
"@types/qrcode": "^1.5.1",
"@types/qs": "^6.9.7",
"@types/showdown": "^2.0.1",
"@types/sortablejs": "^1.15.1",
"@dcore/eslint-config": "workspace:*",
"@dcore/stylelint-config": "workspace:*",
"@dcore/ts-config": "workspace:*",
"@dcore/types": "workspace:*",
"@dcore/vite-config": "workspace:*",
"@vue/compiler-sfc": "^3.3.4",
"@vue/test-utils": "^2.4.0",
"cross-env": "^7.0.3",
"cz-git": "^1.6.1",
"czg": "^1.6.1",
"eslint": "^8.13.0",
"eslint-config-prettier": "^8.5.0",
"eslint-define-config": "^1.1.1",
"eslint-plugin-jest": "^25.2.2",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vue": "^8.6.0",
"husky": "^8.0.3",
"lint-staged": "13.2.3",
"prettier": "^2.8.8",
"prettier-plugin-packagejson": "^2.4.4",
"rimraf": "^5.0.1",
"turbo": "^1.10.7", // 这里是个关键,后面考试要考
"typescript": "^5.1.6",
"unbuild": "^1.2.1",
"vite": "^4.4.0",
"vite-plugin-mock": "^2.9.6",
"vue-tsc": "^1.8.4"
},
"packageManager": "[email protected]",
"engines": {
"node": ">=16.15.1",
"pnpm": ">=8.1.0"
}
}
# npm 先配置registry私服地址,注意私服地址结尾不要添加“/”否则后期会报错
$ npm config set registry https://nexus.sunwoda.com/repository/npm-group
# 先安装 pnpm 命令
$ npm install [email protected] -g
# 安装 turbo 命令
$ npm install [email protected] -g
# pnpm 命令也配置registry私服地址
$ pnpm config set registry https://nexus.sunwoda.com/repository/npm-group
# 进入项目工程,先拉取依赖
$ pnpm install
# 打包操作
$ pnpm run build
pnpm install
出现error (ERR_INVALID_THIS)的情况具体的报错内容如下:
$ pnpm install
Scope: all 7 workspace projects
internal/eslint-config | WARN deprecated [email protected]
WARN deprecated [email protected]: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
WARN deprecated @iconify/[email protected]: no longer maintained, switch to modern iconify-icon web component
WARN GET https://nexus.sunwoda.com/repository/npm-ptl-hosted/debug error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
WARN GET https://nexus.sunwoda.com/repository/npm-ptl-hosted/graphemer error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
WARN GET https://nexus.sunwoda.com/repository/npm-ptl-hosted/ignore error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
WARN GET https://nexus.sunwoda.com/repository/npm-ptl-hosted/natural-compare-lite error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
WARN GET https://nexus.sunwoda.com/repository/npm-ptl-hosted/semver error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
WARN GET https://nexus.sunwoda.com/repository/npm-ptl-hosted/ts-api-utils error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
WARN GET https://nexus.sunwoda.com/repository/npm-ptl-hosted/@eslint%2Feslintrc error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
WARN GET https://nexus.sunwoda.com/repository/npm-ptl-hosted/@eslint%2Fjs error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
在 nodejs20 版本中,就会出现这个问题,为了解决这个问题,你只需要升级到 pnpm v8.3.1 或更高版本即可。
参考地址:
https://www.wyr.me/post/746
https://blog.csdn.net/qq_19661477/article/details/134234971
pnpm install
出现turbo run stub,run failed: error hashing package files具体的报错内容如下:
$ pnpm install
. postinstall$ turbo run stub
│ ERROR run failed: error hashing package files: git error: 'git status' in /root/abc/limsui/packages/hooks exited with code 129 stderr: error: unknown option `no-renames'
│ usage: git status [options] [--] <pathspec>...
│ -v, --verbose be verbose
│ -s, --short show status concisely
│ -b, --branch show branch information
│ --porcelain machine-readable output
│ --long show status in long format (default)
│ -z, --null terminate entries with NUL
│ -u, --untracked-files[=<mode>]
│ show untracked files, optional modes: all, normal, no. (Default: all)
│ --ignored show ignored files
│ --ignore-submodules[=<when>]
│ ignore changes to submodules, optional when: all, dirty, untracked. (Default: all)
│ --column[=<style>] list untracked files in columns
这个是 turbo v1.10.7 版本的bug,然后升级package.json中turbo的版本到新版本即可,例如: turbo v1.10.8,
参考地址:
https://github.com/vercel/turborepo/issues/5447#issuecomment-1621908600
# 本地npm环境添加镜像
$ npm config set registry https://registry.npmmirror.com
# 安装 pnpm
$ npm i [email protected] -g
# 安装 get-npm-tgz
$ npm i get-npm-tgz -g
# 进入到项目目录中,然后下载依赖
$ pnpm install
# 然后将 pnpm-lock.yaml 转换为:package-lock.json
$ npx pnpm-lock-to-npm-lock ./pnpm-lock.yaml
# 这个命令会把当前文件夹的 package-lock.json 的依赖tgz格式下载下来, 执行成功后所有的依赖会再当前目录的 tgz 文件夹下
$ npx get-npm-tgz
# 然后将tgz文件夹压缩为xz文件,然后上传到桌面云中
$ tar -Jcf tgz.tar.xz tgz
#======= 以下内容再桌面云中执行 =======
# 先解压缩
$ tar -Jxf tgz.tar.xz
# 先设置私服的url并进行登录
$ npm login --registry http://registry.npmjs.com
# 发布 xxxx.tgz 文件
$ npm publish xxxx.tgz
批量的发布脚本
#!/bin/bash
REPOSITORY=https://nexus.sunwoda.com/repository/npm-ptl-hosted
PACKAGES_PATH=./tgz
npm login --registry=$REPOSITORY
for package in $PACKAGES_PATH/*.tgz; do
npm publish --registry=$REPOSITORY $package
done
参考地址:
https://blog.csdn.net/2401_85743969/article/details/141128702
https://www.npmjs.com/package/get-npm-tgz