🐩

Vuepressをインストール中にerror:0308010C:digital envelope routines::unsuppo

2023/08/21に公開

https://vuepress.vuejs.org/guide/getting-started.html
の通りにVuepressをインストールしようとしたところ、このようなエラーが発生した。

yarn create vuepress-site [optionalDirectoryName]

ここは通る。

cd docs
yarn install
yarn dev

ここでyarn devとすると以下のエラーが発生。

docs $ yarn dev
yarn run v1.22.15
$ vuepress dev src
wait Extracting site metadata...
tip Apply theme @vuepress/theme-default ...
warning An error was encountered in plugin "@vuepress/plugin-back-to-top"
warning An error was encountered in plugin "@vuepress/plugin-medium-zoom"
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/active-header-links (i.e. "@vuepress/plugin-active-header-links") ...
tip Apply plugin @vuepress/search (i.e. "@vuepress/plugin-search") ...
tip Apply plugin @vuepress/nprogress (i.e. "@vuepress/plugin-nprogress") ...


● Client █████████████████████████ building (40%) 1/2 modules 1 active
 node_modules/webpack/hot/dev-server.js

ℹ 「wds」: Project is running at http://0.0.0.0:8081/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: Content not from webpack is served from /Library/WebServer/Documents/vuepress/docs/src/.vuepress/public
ℹ 「wds」: 404s will fallback to /index.html
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 (/Library/WebServer/Documents/vuepress/docs/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/Library/WebServer/Documents/vuepress/docs/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/Library/WebServer/Documents/vuepress/docs/node_modules/webpack/lib/NormalModule.js:471:10)
    at /Library/WebServer/Documents/vuepress/docs/node_modules/webpack/lib/NormalModule.js:503:5
    at /Library/WebServer/Documents/vuepress/docs/node_modules/webpack/lib/NormalModule.js:358:12
    at /Library/WebServer/Documents/vuepress/docs/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/Library/WebServer/Documents/vuepress/docs/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at Array.<anonymous> (/Library/WebServer/Documents/vuepress/docs/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
    at Storage.finished (/Library/WebServer/Documents/vuepress/docs/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
    at /Library/WebServer/Documents/vuepress/docs/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
    at /Library/WebServer/Documents/vuepress/docs/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.15.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

エラーメッセージError: error:0308010C:デジタル・エンベロープ・ルーチン::unsupportedは、OpenSSLのバージョンまたはNode.jsとの統合に問題があることを示しているそうだ。

問題は使用していたNode.js v18.15.0のようだ(Node.jsの新しいバージョンでは、特定のパッケージやライブラリとの互換性に問題がある場合があります)。そこでダウングレードしてみる。

バージョンの違うNode.jsを管理するためにnvmを使う。

nvm install 14.18.0
nvm use 14.18.0

これで、

yarn dev

とすると、無事起動した!

Discussion