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
Error: error:0308010C:digital envelope routines::unsupported
Solution: Open the legacy OpenSSL provider, add the following command in package.json
the 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