From 2c6b593a859e22d20c120d640c08106bd411b9f2 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 20 Feb 2023 20:28:43 +0000 Subject: [PATCH] fix(config): upgrade md4 -> md5 on node > 16 (#19108) --- packages/config/src/options.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/config/src/options.js b/packages/config/src/options.js index fb12f84cbe..16f38e547b 100644 --- a/packages/config/src/options.js +++ b/packages/config/src/options.js @@ -519,6 +519,17 @@ export function getNuxtConfig (_options) { options.build.indicator = false } + // Monkey patch crypto.createHash in dev/build to upgrade hashing fnction + if (parseInt(process.versions.node.slice(0, 2)) > 16) { + options.buildModules.push(function patchMD4 () { + const crypto = require('crypto') + const _createHash = crypto.createHash + crypto.createHash = function (algorithm, options) { + return _createHash(algorithm === 'md4' ? 'md5' : algorithm, options) + } + }) + } + // Components Module if (!options._start && getPKG('@nuxt/components')) { options._modules.push('@nuxt/components')