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

Package.json file before change

{
    
    
  "name": "djangomall",
  "version": "0.0.0",
  "description": "djangomall app",
  "main": "index.js",
  "scripts": {
    
    
    "watch": "webpack --mode=development --progress --watch",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "jacky",
  "license": "ISC",
  "devDependencies": {
    
    
    "cross-env": "^7.0.2",
    "webpack": "^4.43.0",
    "webpack-bundle-tracker": "^0.4.3",
    "webpack-cli": "^3.3.11"
  }
}

An error is reported after running npm run watch

insert image description here
insert image description here

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

Solution: Open the legacy OpenSSL provider, add the following command in package.jsonthe file scripts, the Windows solution is as follows:

set NODE_OPTIONS=–openssl-legacy-provider &&

The changed package.json file is as follows:

{
    
    
  "name": "djangomall",
  "version": "0.0.0",
  "description": "djangomall app",
  "main": "index.js",
  "scripts": {
    
    
    "watch": "set NODE_OPTIONS=--openssl-legacy-provider && webpack --mode=development --progress --watch",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "jacky",
  "license": "ISC",
  "devDependencies": {
    
    
    "cross-env": "^7.0.2",
    "webpack": "^4.43.0",
    "webpack-bundle-tracker": "^0.4.3",
    "webpack-cli": "^3.3.11"
  }
}

Under Linux, it is as follows:export NODE_OPTIONS=--openssl-legacy-provider

Guessing the cause of the error : using a higher version of Node.js, and then using webpack4, my Node.js is v18.15.0

Guess you like

Origin blog.csdn.net/weixin_43883625/article/details/129912334