前言:想搭建一个自己写笔记的博客,然后看了Docsify和Hexo,决定先用vuepress搭建一个,我就按照官网上的开始喽,哈哈哈哈,就开始了我的踩坑之旅了
我按照官网的步骤走下去,yarn dev直接给我了报错????
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 (/Users/artist/qm/vuepress-starter/node_modules/webpack/lib/util/createHash.js:135:53)
at NormalModule._initBuildHash (/Users/artist/qm/vuepress-starter/node_modules/webpack/lib/NormalModule.js:417:16)
at handleParseError (/Users/artist/qm/vuepress-starter/node_modules/webpack/lib/NormalModule.js:471:10)
at /Users/artist/qm/vuepress-starter/node_modules/webpack/lib/NormalModule.js:503:5
at /Users/artist/qm/vuepress-starter/node_modules/webpack/lib/NormalModule.js:358:12
at /Users/artist/qm/vuepress-starter/node_modules/loader-runner/lib/LoaderRunner.js:373:3
at iterateNormalLoaders (/Users/artist/qm/vuepress-starter/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
at Array.<anonymous> (/Users/artist/qm/vuepress-starter/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
at Storage.finished (/Users/artist/qm/vuepress-starter/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
at /Users/artist/qm/vuepress-starter/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
at /Users/artist/qm/vuepress-starter/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.12.1
此时我的node版本号是V18.12.1,然后我就去喂chatGPT,他告诉我可能是node版本号过高造成的,所以我尝试降低node版本号
nvm ls
nvm use v16.18.1
我再次yarn dev,哈哈哈哈成功了
虽然成功了,但我并不知道为什么会报错? 详细报错原因如下:
主要是nodeJs V17版本发布了OpenSSL3.0对算法和密钥大小增加了更为严格的限制。 所以就是node版本太高不兼容导致运行失败
我又去网上查找其他不用降低node版本的方案,如下
- 方法一
"scripts": {
"dev": "set NODE_OPTIONS=--openssl-legacy-provider & vuepress dev docs",
"build": "set NODE_OPTIONS=--openssl-legacy-provider & vuepress build docs"
}
但是我发现并没有成功,还是报错的
- 方法二
在编译器的集成终端运行命令行:$env:NODE_OPTIONS="--openssl-legacy-provider",在运行yarn dev
很失望的是这个也是没有成功的
最终还是降低node版本最好用