npm run dev Error: error:0308010C:digital envelope routines::unsupported

Introduction

For next 13 project, an error was reported when running npm run dev

Error: error:0308010C:digital envelope routines::unsupported

The analysis found that Node.js v17 and above are usually installed, and then webpack4 is used.

Solution One

Downgrade to v16 version. You can reinstall the v16 version directly, or use gnvm to switch versions

gnvm switch node version tutorial

Solution Two

Enable legacy OpenSSL provider

Windows

set NODE_OPTIONS=--openssl-legacy-provider

Linux or Mac

export NODE_OPTIONS=--openssl-legacy-provider

Solution Three

Set the variable NODE_OPTIONS=--openssl-legacy-provider before the dev directive in package.json

change to this

"dev": "cross-env NODE_OPTIONS=--openssl-legacy-provider next dev",
  "dependencies": {
     "cross-env": "^7.0.3",
}

Make sure you have cross-env installed. If other commands report errors, the same is true.

Reference

Comments