Angular - 信封例程::不支持

问题描述 投票:0回答:1

我的角度应用程序有问题。我每年只工作一两次来更新内容。

当我想导出时又遇到了这个问题:

10% building 4/5 modules 1 active D:\wamp64\www\sites\ecarte\node_modules\@angular-devkit\build-angular\src\angular-cli-files\models\es5-polyfills.jsnode:internal/crypto/hash:69
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:69:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (D:\wamp64\www\sites\ecarte\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\util\createHash.js:135:53)
    at NormalModule._initBuildHash (D:\wamp64\www\sites\ecarte\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\NormalModule.js:417:16)
    at D:\wamp64\www\sites\ecarte\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\NormalModule.js:452:10
    at D:\wamp64\www\sites\ecarte\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\NormalModule.js:323:13
    at D:\wamp64\www\sites\ecarte\node_modules\loader-runner\lib\LoaderRunner.js:367:11
    at D:\wamp64\www\sites\ecarte\node_modules\loader-runner\lib\LoaderRunner.js:203:19
    at VirtualFileSystemDecorator.readFile (D:\wamp64\www\sites\ecarte\node_modules\@ngtools\webpack\src\virtual_file_system_decorator.js:46:13)
    at processResource (D:\wamp64\www\sites\ecarte\node_modules\loader-runner\lib\LoaderRunner.js:202:11)
    at iteratePitchingLoaders (D:\wamp64\www\sites\ecarte\node_modules\loader-runner\lib\LoaderRunner.js:158:10)
    at runLoaders (D:\wamp64\www\sites\ecarte\node_modules\loader-runner\lib\LoaderRunner.js:365:2)
    at NormalModule.doBuild (D:\wamp64\www\sites\ecarte\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\NormalModule.js:295:3)
    at NormalModule.build (D:\wamp64\www\sites\ecarte\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\NormalModule.js:446:15)
    at Compilation.buildModule (D:\wamp64\www\sites\ecarte\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:739:10)
    at D:\wamp64\www\sites\ecarte\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:981:14 {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

我设法用这些解决方案解决了这个问题: 不支持数字信封例程

但是这次即使我在 package.json 文件中添加 NODE_OPTION 命令并在命令提示符中键入该命令,它也不起作用。 我最近切换到 Windows 11。这可能有关系吗?

我将 nvm 与 Node.js 18.20.3 结合使用,这是我的 package.json:

{
  "name": "client-app",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "lrf": "ng serve --aot --live-reload=false",
    "build": "set NODE_OPTIONS=--openssl-legacy-provider && ng build ",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~9.1.9",
    "@angular/cdk": "^9.2.4",
    "@angular/common": "~9.1.9",
    "@angular/compiler": "~9.1.9",
    "@angular/core": "~9.1.9",
    "@angular/forms": "~9.1.9",
    "@angular/material": "^9.2.4",
    "@angular/platform-browser": "~9.1.9",
    "@angular/platform-browser-dynamic": "~9.1.9",
    "@angular/router": "~9.1.9",
    "moment": "^2.26.0",
    "ngx-google-analytics": "^9.0.0",
    "ngx-socket-io": "^3.0.1",
    "ngx-swiper-wrapper": "^9.0.1",
    "ngx-useful-swiper": "^9.0.3",
    "rxjs": "~6.5.4",
    "swiper": "^5.4.1",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.901.7",
    "@angular/cli": "~9.1.7",
    "@angular/compiler-cli": "~9.1.9",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "@types/swiper": "^5.3.1",
    "codelyzer": "^5.1.2",
    "jasmine-core": "~3.5.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"
  }
}

你有解决办法吗?预先感谢

编辑:我运行

ng build
命令来使用本地版本的 Angular,而不是运行
npx ng build
命令。感谢@JSON Derulo 的提示

angular webpack angular-cli
1个回答
0
投票

Angular 9 不支持 Node 18:https://angular.dev/reference/versions#unsupported-angular-versions 所以你需要将 Node 降级到 v10 或 v12。

此外,请确保通过运行

npx ng build
使用本地安装的 Angular CLI 版本。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.