I'm experiencing the "DeprecationWarning" error and Hash Algorithm Error when running ng serve in my Angular project. I've tried various solutions, but the issue persists.
Here's what I've tried:
- Deleted node_modules and reinstalled dependencies with npm install.
- Used different Node.js versions, including LTS versions like 16.14.2 and 18.13.0 (current).
- Upgraded Angular CLI to the latest version (17.0.7).
- Tried different Angular versions, including the latest (17.0.7).
- Cleared npm cache with npm cache clean --force.
- Set the NODE_OPTIONS=--openssl-legacy-provider environment variable (temporary workaround). Error Details:
10% building 3/4 modules 1 active ...erver/client/index.js?http://0.0.0.0:0/sockjs-node&sockPath=/sockjs-nodenode:internal/crypto/hash:71 this[kHandle] = new _Hash(algorithm, xofLen); ^
Error: error:0308010C:digital envelope routines::unsupported at new Hash (node:internal/crypto/hash:71:19) at Object.createHash (node:crypto:133:10) ... (stack trace continues)
Node.js v18.13.0 Angular CLI v17.0.7
Additional Information:
Operating System: Ub Webpack version: 9.1.13
package.json file -
{
"name": "frontend2",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~9.1.13",
"@angular/common": "~9.1.13",
"@angular/compiler": "~9.1.13",
"@angular/core": "~9.1.13",
"@angular/forms": "~9.1.13",
"@angular/platform-browser": "~9.1.13",
"@angular/platform-browser-dynamic": "~9.1.13",
"@angular/router": "~9.1.13",
"rxjs": "~6.5.4",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.901.13",
"@angular/cli": "~9.1.13",
"@angular/compiler-cli": "~9.1.13",
"@types/node": "^12.11.1",
"@types/jasmine": "~3.8.0",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "^5.1.2",
"jasmine-core": "~3.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~3.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~3.8.3"
}
}