这是因为Node.js17+中的OpenSSL加密库不支持当前的加密设置。
因为新版本默认使用OpenSSL 3,它可能不再支持旧版的加密算法或配置。
> demo@0.1.0 serve
> vue-cli-service serve
INFO Starting development server...
10% building 2/5 modules 3 active ...\vue\node_modules\babel-loader\lib\index.js!E:\xianyu\dormitory_manager_system\vue\src\main.jsE
rror: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:69:19)
at Object.createHash (node:crypto:133:10)
at module.exports (E:\xianyu\dormitory_manager_system\vue\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (E:\xianyu\dormitory_manager_system\vue\node_modules\webpack\lib\NormalModule.js:417:16)
at handleParseError (E:\xianyu\dormitory_manager_system\vue\node_modules\webpack\lib\NormalModule.js:471:10)
at E:\xianyu\dormitory_manager_system\vue\node_modules\webpack\lib\NormalModule.js:503:5
at E:\xianyu\dormitory_manager_system\vue\node_modules\webpack\lib\NormalModule.js:358:12
at E:\xianyu\dormitory_manager_system\vue\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (E:\xianyu\dormitory_manager_system\vue\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at iterateNormalLoaders (E:\xianyu\dormitory_manager_system\vue\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
at E:\xianyu\dormitory_manager_system\vue\node_modules\loader-runner\lib\LoaderRunner.js:236:3
at runSyncOrAsync (E:\xianyu\dormitory_manager_system\vue\node_modules\loader-runner\lib\LoaderRunner.js:130:11)
at iterateNormalLoaders (E:\xianyu\dormitory_manager_system\vue\node_modules\loader-runner\lib\LoaderRunner.js:232:2)
at Array.<anonymous> (E:\xianyu\dormitory_manager_system\vue\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
at Storage.finished (E:\xianyu\dormitory_manager_system\vue\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
at E:\xianyu\dormitory_manager_system\vue\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
node:internal/crypto/hash:69
this[kHandle] = new _Hash(algorithm, xofLen);
^
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:69:19)
at Object.createHash (node:crypto:133:10)
at module.exports (E:\xianyu\dormitory_manager_system\vue\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (E:\xianyu\dormitory_manager_system\vue\node_modules\webpack\lib\NormalModule.js:417:16)
at handleParseError (E:\xianyu\dormitory_manager_system\vue\node_modules\webpack\lib\NormalModule.js:471:10)
at E:\xianyu\dormitory_manager_system\vue\node_modules\webpack\lib\NormalModule.js:503:5
at E:\xianyu\dormitory_manager_system\vue\node_modules\webpack\lib\NormalModule.js:358:12
at E:\xianyu\dormitory_manager_system\vue\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (E:\xianyu\dormitory_manager_system\vue\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at Array.<anonymous> (E:\xianyu\dormitory_manager_system\vue\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
at Storage.finished (E:\xianyu\dormitory_manager_system\vue\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
at E:\xianyu\dormitory_manager_system\vue\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
at E:\xianyu\dormitory_manager_system\vue\node_modules\graceful-fs\graceful-fs.js:123:16
at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}
Node.js v18.17.1
如果你和我一样不想升级项目中的依赖,也不想降低node.js的版本,只需要设置环境变量 NODE_OPTIONS
来指定使用OpenSSL的遗留提供者(legacy provider),在控制台输入 ,再运行就OK
$env:NODE_OPTIONS="--openssl-legacy-provider"