next.js: Node.js v17.0.0 - Error starting project in development mode

What version of Next.js are you using?

11.1.2

What version of Node.js are you using?

17.0.0

What browser are you using?

Chrome 94.0.4606.81

What operating system are you using?

Windows 10

How are you deploying your application?

/

Describe the Bug

After updating Node.js to the new version, when starting the project in development mode, the following error is obtained in the terminal.

> test@0.1.0 dev
> next dev

ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:130:10)
    at BulkUpdateDecorator.hashFactory (C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack\bundle5.js:138971:18)
    at BulkUpdateDecorator.update (C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack\bundle5.js:138872:50)
    at OriginalSource.updateHash (C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack-sources3\index.js:1:10264)
    at NormalModule._initBuildHash (C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack\bundle5.js:68468:17)
    at handleParseResult (C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack\bundle5.js:68534:10)
    at C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack\bundle5.js:68628:4
    at processResult (C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack\bundle5.js:68343:11)
    at C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack\bundle5.js:68407:5
Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:130:10)
    at BulkUpdateDecorator.hashFactory (C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack\bundle5.js:138971:18)
    at BulkUpdateDecorator.update (C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack\bundle5.js:138872:50)
    at OriginalSource.updateHash (C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack-sources3\index.js:1:10264)
    at NormalModule._initBuildHash (C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack\bundle5.js:68468:17)
    at handleParseResult (C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack\bundle5.js:68534:10)
    at C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack\bundle5.js:68628:4
    at processResult (C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack\bundle5.js:68343:11)
    at C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack\bundle5.js:68407:5
node:internal/crypto/hash:67
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:130:10)
    at BulkUpdateDecorator.hashFactory (C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack\bundle5.js:138971:18)
    at BulkUpdateDecorator.update (C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack\bundle5.js:138872:50)
    at OriginalSource.updateHash (C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack-sources3\index.js:1:10264)
    at NormalModule._initBuildHash (C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack\bundle5.js:68468:17)
    at handleParseResult (C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack\bundle5.js:68534:10)
    at C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack\bundle5.js:68628:4
    at processResult (C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack\bundle5.js:68343:11)
    at C:\Users\DyauS\Documents\test\node_modules\next\dist\compiled\webpack\bundle5.js:68407:5 {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Node.js v17.0.0

Expected Behavior

The project is expected to be launched successfully.

To Reproduce

Update Node.js version to 17.0.0, create a new Next.js app using create-next-app and start Next.js in development mode.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 13
  • Comments: 31 (13 by maintainers)

Commits related to this issue

Most upvoted comments

Error present on NextJS 12.0.1 as well.

as @foxscotch said but as a 1 liner for those that are unfamiliar:

NODE_OPTIONS=--openssl-legacy-provider yarn dev

Itโ€™s fixed in webpack/webpack#14532, weโ€™re going to create a new release of webpack and upgrade it in Next.js ๐Ÿ‘

Verified Error: error:0308010C:digital envelope routines::unsupported no longer happens using next@canary ๐Ÿ‘

This will be fixed by #30743. Note that issue open === not fixed. You donโ€™t have to confirm that the issue is not fixed when the issue is open on GitHub.

I get this when I try to build the recommended docker file from https://nextjs.org/docs/deployment

Maybe downgrade the docker image to node 16 until the issue is resolved?

EDIT: Solved this by changing all instances of FROM node:alpine AS deps to FROM node:16-alpine AS deps in Dockerfile given in https://nextjs.org/docs/deployment

Hi, this has been updated in v11.1.3-canary.89 of Next.js, please update and give it a try!

Hi, this has been updated in v12.0.3-canary.2 of Next.js, please update and give it a try!

{
  ...
  "scripts": {
    "dev": "export NODE_OPTIONS=--openssl-legacy-provider; next dev",
    "build": "export NODE_OPTIONS=--openssl-legacy-provider; next build",
    ...
  },
 ...
}

@Osama-Z-Ansari - put it in package.json

@gunnartorfis as @fbwoolf pointed out above, changing the alpine image in the docker file to FROM node:16-alpine AS deps is a workaround.

sha1 might be a good choice for hashing with bundles

Better to use xxhash64, we already is doing it if you set experiments: { futureDefaults: true } https://github.com/webpack/webpack/blob/main/lib/config/defaults.js#L824

@pkellner this issue happens because of Node.js 17, so itโ€™s probably that youโ€™re using an image to does not have a pinned version.

Experiencing same problem v16.13.0

this seems to be a broader webpack issue, rather than Next-specific. @akornatskyy provided a temporary workaround in an issue from the webpack repo webpack/webpack#14532. in short, you need the --openssl-legacy-provider argument to be provided to node; they suggested using the NODE_OPTIONS environment variable, which did the job for me

The reason is here: https://medium.com/the-node-js-collection/node-js-17-is-here-8dba1e14e382 node no longer supports md4 as hash function. sha1 might be a good choice for hashing with bundles.