前言
vue2前端项目在服务器上打包报错,发现是高版本的node使用的是OpenSSL 3.0,导致的不兼容,所以先临时抛出下环境变量,继续使用老板本的OpenSSL的实现;
步骤
解决方法
代码语言:javascript复制export NODE_OPTIONS=--openssl-legacy-provider
具体报错信息
代码语言:javascript复制root@iZuf6f5trc95ufa25hqb6eZ:/www/wwwroot/ad-client# pnpm run build
> oceane_front@0.1.0 build /www/wwwroot/ad-client
> vue-cli-service build
⠹ Building for production...Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:71:19)
at Object.createHash (node:crypto:133:10)
at module.exports (/www/wwwroot/ad-client/node_modules/.pnpm/webpack@4.46.0/node_modules/webpack/lib/util/createHash.js:135:53)
at NormalModule._initBuildHash (/www/wwwroot/ad-client/node_modules/.pnpm/webpack@4.46.0/node_modules/webpack/lib/NormalModule.js:417:16)
at handleParseError (/www/wwwroot/ad-client/node_modules/.pnpm/webpack@4.46.0/node_modules/webpack/lib/NormalModule.js:471:10)
at /www/wwwroot/ad-client/node_modules/.pnpm/webpack@4.46.0/node_modules/webpack/lib/NormalModule.js:503:5
at /www/wwwroot/ad-client/node_modules/.pnpm/webpack@4.46.0/node_modules/webpack/lib/NormalModule.js:358:12
at /www/wwwroot/ad-client/node_modules/.pnpm/loader-runner@2.4.0/node_modules/loader-runner/lib/LoaderRunner.js:373:3
at iterateNormalLoaders (/www/wwwroot/ad-client/node_modules/.pnpm/loader-runner@2.4.0/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
at iterateNormalLoaders (/www/wwwroot/ad-client/node_modules/.pnpm/loader-runner@2.4.0/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
at /www/wwwroot/ad-client/node_modules/.pnpm/loader-runner@2.4.0/node_modules/loader-runner/lib/LoaderRunner.js:236:3
at runSyncOrAsync (/www/wwwroot/ad-client/node_modules/.pnpm/loader-runner@2.4.0/node_modules/loader-runner/lib/LoaderRunner.js:130:11)
at iterateNormalLoaders (/www/wwwroot/ad-client/node_modules/.pnpm/loader-runner@2.4.0/node_modules/loader-runner/lib/LoaderRunner.js:232:2)
at Array.<anonymous> (/www/wwwroot/ad-client/node_modules/.pnpm/loader-runner@2.4.0/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
at Storage.finished (/www/wwwroot/ad-client/node_modules/.pnpm/enhanced-resolve@4.5.0/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
at /www/wwwroot/ad-client/node_modules/.pnpm/enhanced-resolve@4.5.0/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
⠋ Building for production.../www/wwwroot/ad-client/node_modules/.pnpm/loader-runner@2.4.0/node_modules/loader-runner/lib/LoaderRunner.js:114
throw e;
^
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:71:19)
at Object.createHash (node:crypto:133:10)
at module.exports (/www/wwwroot/ad-client/node_modules/.pnpm/webpack@4.46.0/node_modules/webpack/lib/util/createHash.js:135:53)
at NormalModule._initBuildHash (/www/wwwroot/ad-client/node_modules/.pnpm/webpack@4.46.0/node_modules/webpack/lib/NormalModule.js:417:16)
at handleParseError (/www/wwwroot/ad-client/node_modules/.pnpm/webpack@4.46.0/node_modules/webpack/lib/NormalModule.js:471:10)
at /www/wwwroot/ad-client/node_modules/.pnpm/webpack@4.46.0/node_modules/webpack/lib/NormalModule.js:503:5
at /www/wwwroot/ad-client/node_modules/.pnpm/webpack@4.46.0/node_modules/webpack/lib/NormalModule.js:358:12
at /www/wwwroot/ad-client/node_modules/.pnpm/loader-runner@2.4.0/node_modules/loader-runner/lib/LoaderRunner.js:373:3
at iterateNormalLoaders (/www/wwwroot/ad-client/node_modules/.pnpm/loader-runner@2.4.0/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
at iterateNormalLoaders (/www/wwwroot/ad-client/node_modules/.pnpm/loader-runner@2.4.0/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
at /www/wwwroot/ad-client/node_modules/.pnpm/loader-runner@2.4.0/node_modules/loader-runner/lib/LoaderRunner.js:236:3
at context.callback (/www/wwwroot/ad-client/node_modules/.pnpm/loader-runner@2.4.0/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
at /www/wwwroot/ad-client/node_modules/.pnpm/cache-loader@4.1.0_webpack@4.46.0/node_modules/cache-loader/dist/index.js:147:7
at /www/wwwroot/ad-client/node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js:61:14
at FSReqCallback.oncomplete (node:fs:198:23) {
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}
Node.js v18.16.0