目录
报错情况
Error: error:0308010C:digital envelope routines::unsupported
[1] at new Hash (node:internal/crypto/hash:68:19)
[1] at Object.createHash (node:crypto:138:10)
[1] at module.exports (D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\webpack\lib\util\createHash.js:135:53)
[1] at NormalModule._initBuildHash (D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\webpack\lib\NormalModule.js:417:16)
[1] at handleParseError (D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\webpack\lib\NormalModule.js:471:10)
[1] at D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\webpack\lib\NormalModule.js:503:5
[1] at D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\webpack\lib\NormalModule.js:358:12
[1] at D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\loader-runner\lib\LoaderRunner.js:373:3
[1] at iterateNormalLoaders (D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
[1] at iterateNormalLoaders (D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
[1] at D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\loader-runner\lib\LoaderRunner.js:236:3
[1] at runSyncOrAsync (D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\loader-runner\lib\LoaderRunner.js:130:11)
[1] at iterateNormalLoaders (D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\loader-runner\lib\LoaderRunner.js:232:2)
[1] at Array.<anonymous> (D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
[1] at Storage.finished (D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
[1] at D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
[1] <s> [webpack.Progress] 10% building 2/5 modules 3 active D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\cache-loader\dist\cjs.js??ref--14-0!D:\WorkSpaces\WebStormS
pace\vue3-composition-admin\node_modules\babel-loader\lib\index.js!D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\ts-loader\index.js??ref--14-2!D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\eslint-loader\index.js??ref--13-0!D:\WorkSpaces\WebStormSpace\vue3-composition-admin\src\main.ts
[1] node:internal/crypto/hash:68
[1] this[kHandle] = new _Hash(algorithm, xofLen);
[1] ^
[1]
[1] Error: error:0308010C:digital envelope routines::unsupported
[1] at new Hash (node:internal/crypto/hash:68:19)
[1] at Object.createHash (node:crypto:138:10)
[1] at module.exports (D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\webpack\lib\util\createHash.js:135:53)
[1] at NormalModule._initBuildHash (D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\webpack\lib\NormalModule.js:417:16)
[1] at handleParseError (D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\webpack\lib\NormalModule.js:471:10)
[1] at D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\webpack\lib\NormalModule.js:503:5
[1] at D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\webpack\lib\NormalModule.js:358:12
[1] at D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\loader-runner\lib\LoaderRunner.js:373:3
[1] at iterateNormalLoaders (D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
[1] at Array.<anonymous> (D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
[1] at Storage.finished (D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
[1] at D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
[1] at D:\WorkSpaces\WebStormSpace\vue3-composition-admin\node_modules\graceful-fs\graceful-fs.js:123:16
[1] at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read/context:68:3) {
[1] opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
[1] library: 'digital envelope routines',
[1] reason: 'unsupported',
[1] code: 'ERR_OSSL_EVP_UNSUPPORTED'
报错原因
这个错误信息 通常出现在Node.js的新版本中,特别是从Node.js v17开始,因为默认启用了OpenSSL 3,它使用了新的加密提供者,而某些Node.js的依赖可能还不支持这种新的提供者。
解决办法
-
设置环境变量 :
通过设置环境变量
NODE_OPTIONS
来指示Node.js使用旧的加密提供者。在Windows上,你可以通过命令行设置这个环境变量:
bash复制代码
|---|----------------------------------------------|
| |set NODE_OPTIONS=--openssl-legacy-provider
|或者在你的系统环境变量中永久添加这个设置。
在Linux或macOS上,你可以在你的shell配置文件中(如
.bashrc
、.zshrc
等)添加:bash复制代码
|---|-------------------------------------------------|
| |export NODE_OPTIONS=--openssl-legacy-provider
|然后运行
source ~/.bashrc
或source ~/.zshrc
来使改动生效。 -
降级Node.js版本 :
如果上述方法不可行或你不希望改变环境变量,你可以考虑降级Node.js到一个较旧的版本,比如Node.js v16,它可能与你当前的webpack版本和其他依赖更加兼容。
-
更新webpack和相关依赖 :
如果你正在使用的webpack版本较旧,那么尝试更新到最新稳定版本可能有助于解决这个问题。同样的,检查并更新其他相关依赖也是一个好主意。
-
检查项目依赖 :
查看
package.json
文件,确保所有的依赖都是最新的,并且彼此兼容。有时候,某个特定的依赖版本可能与当前的Node.js版本不兼容。