命令
CMD
npm run dev
异常
cmd
> theme-vdoing-doc@1.0.0 dev
> vuepress dev docs
wait Extracting site metadata...
warning An error was encountered in theme "J:\xxx\xxx\xxxxxl\theme"
tip Apply theme vuepress-theme-index ...
warning An error was encountered in plugin "thirdparty-search"
warning An error was encountered in plugin "one-click-copy"
warning An error was encountered in plugin "demo-block"
warning An error was encountered in plugin "vuepress-plugin-zooming"
tip Apply plugin container (i.e. "vuepress-plugin-container") ...
tip Apply plugin @vuepress/register-components (i.e. "@vuepress/plugin-register-components") ...
tip Apply plugin @vuepress/last-updated (i.e. "@vuepress/plugin-last-updated") ...
* Client █████████████████████████ building (40%) 1/2 modules 1 active
C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\webpack-dev-server\client\index.js
i 「wds」: Project is running at http://0.0.0.0:8080/
i 「wds」: webpack output is served from /
i 「wds」: Content not from webpack is served from J:\xxx\xx\xxl\ma\docs\.vuepress\public
i 「wds」: 404s will fallback to /index.html
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 (C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\webpack\lib\NormalModule.js:417:16)
at handleParseError (C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\webpack\lib\NormalModule.js:471:10)
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\webpack\lib\NormalModule.js:503:5
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\webpack\lib\NormalModule.js:358:12
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at iterateNormalLoaders (C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\loader-runner\lib\LoaderRunner.js:236:3
at runSyncOrAsync (C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\loader-runner\lib\LoaderRunner.js:130:11)
at iterateNormalLoaders (C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\loader-runner\lib\LoaderRunner.js:232:2)
at Array.<anonymous> (C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
at Storage.finished (C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
node:internal/crypto/hash:71
this[kHandle] = new _Hash(algorithm, xofLen);
^
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 (C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\webpack\lib\NormalModule.js:417:16)
at handleParseError (C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\webpack\lib\NormalModule.js:471:10)
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\webpack\lib\NormalModule.js:503:5
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\webpack\lib\NormalModule.js:358:12
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at Array.<anonymous> (C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
at Storage.finished (C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\vuepress\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.16.0
从报错信息中的核心要素
- Error: error:0308010C:digital envelope routines::unsupported
这个错误通常与OpenSSL库有关,它是Node.js用于加密操作的底层库。这个错误代码意味着Node.js试图使用一个不受当前OpenSSL版本支持的哈希算法。这通常发生在Node.js版本与OpenSSL版本之间的不兼容性上.
由于VuePress和其依赖项可能依赖于特定版本的Node.js和OpenSSL,因此当使用的Node.js版本过旧时,可能会出现这种不兼容的情况。更新Node.js通常会解决这类问题,因为新版本的Node.js通常会包含更新后的OpenSSL库,这些库支持更多的哈希算法。
此外,报错信息中提到了webpack,这是VuePress用于构建项目的工具。Webpack也可能依赖于特定版本的Node.js,因此确保所有依赖项都是最新的,并且与你的Node.js版本兼容,是解决这类问题的关键。
总结来说,报错信息中的unsupported和digital envelope routines提示了与加密相关的底层库可能存在版本不兼容的问题,而解决这个问题的一个常见方法是更新Node.js到一个支持这些加密操作的较新版本。
解决方案
使用版本兼容
更新VuePress和它的依赖
cmd
npm update -g vuepress
全局安装的VuePress到最新版本
cmd
npm update vuepress
如果VuePress是作为一个项目依赖安装的,你需要进入项目目录,然后运行:
关于nodejs版本
可以通过nvm来切换不同版本的版本。