nuxt / vercel-builder

Vercel Builder for Nuxt
MIT License
645 stars 75 forks source link

[nuxt2] vercel build fails with node v18.12.1 #761

Closed hartmut-co-uk closed 1 year ago

hartmut-co-uk commented 1 year ago

Nuxt2 project vercel deployment fails at build step, runs into an error Error: error:0308010C:digital envelope routines::unsupported running on node v18.12.1.

For my project this has started to occur with @nuxt/vercel-builder@0.24.0 where vercel ignores my project level defined node version (16.x).

For reference, the build fails with following error:

(...)
----------------- Nuxt build -----------------
--
00:02:54.644 | Running nuxt build --standalone --no-lock --config-file "nuxt.config.js" /vercel/path1
00:02:59.583 | node:internal/crypto/hash:71
00:02:59.584 | this[kHandle] = new _Hash(algorithm, xofLen);
00:02:59.584 | ^
00:02:59.584 |  
00:02:59.584 | Error: error:0308010C:digital envelope routines::unsupported
00:02:59.584 | at new Hash (node:internal/crypto/hash:71:19)
00:02:59.585 | at Object.createHash (node:crypto:133:10)
00:02:59.585 | at module.exports (/vercel/path1/node_modules/webpack/lib/util/createHash.js:135:53)
00:02:59.585 | at NormalModule._initBuildHash (/vercel/path1/node_modules/webpack/lib/NormalModule.js:417:16)
00:02:59.585 | at handleParseError (/vercel/path1/node_modules/webpack/lib/NormalModule.js:471:10)
00:02:59.585 | at /vercel/path1/node_modules/webpack/lib/NormalModule.js:503:5
00:02:59.586 | at /vercel/path1/node_modules/webpack/lib/NormalModule.js:358:12
00:02:59.586 | at /vercel/path1/node_modules/loader-runner/lib/LoaderRunner.js:373:3
00:02:59.586 | at iterateNormalLoaders (/vercel/path1/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
00:02:59.586 | at Array.<anonymous> (/vercel/path1/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
00:02:59.586 | at Storage.finished (/vercel/path1/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
00:02:59.587 | at /vercel/path1/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
00:02:59.588 | at /vercel/path1/node_modules/graceful-fs/graceful-fs.js:123:16
00:02:59.589 | at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
00:02:59.589 | opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
00:02:59.589 | library: 'digital envelope routines',
00:02:59.589 | reason: 'unsupported',
00:02:59.589 | code: 'ERR_OSSL_EVP_UNSUPPORTED'
00:02:59.589 | }
00:02:59.589 |  
00:02:59.589 | Node.js v18.12.1
00:02:59.608 | Error: Command failed with exit code 1: npx nuxt build --standalone --no-lock --config-file "nuxt.config.js" /vercel/path1
hartmut-co-uk commented 1 year ago

Defining the required Node.js version in package.json solves this for me:

  "engines": {
    "node": ">=16.0.0 <17.0.0"
  },