我创建了默认的IntelliJ IDEA React项目,并得到了这个:

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:130:10)
    at module.exports (/Users/user/Programming Documents/WebServer/untitled/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/Users/user/Programming Documents/WebServer/untitled/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/Users/user/Programming Documents/WebServer/untitled/node_modules/webpack/lib/NormalModule.js:471:10)
    at /Users/user/Programming Documents/WebServer/untitled/node_modules/webpack/lib/NormalModule.js:503:5
    at /Users/user/Programming Documents/WebServer/untitled/node_modules/webpack/lib/NormalModule.js:358:12
    at /Users/user/Programming Documents/WebServer/untitled/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/Users/user/Programming Documents/WebServer/untitled/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at iterateNormalLoaders (/Users/user/Programming Documents/WebServer/untitled/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
/Users/user/Programming Documents/WebServer/untitled/node_modules/react-scripts/scripts/start.js:19
  throw err;
  ^

这似乎是最近才出现的问题——webpack在4天前遇到了这个问题,目前仍在处理。


当前回答

听起来很简单,如果可行的话,升级包中的所有依赖项。json到最新的(只要在npm中输入名称并使用建议的版本),也使用node的最新LTS版本。

我以前遇到过问题,即使将我的项目迁移到使用yarn,我也能够最终解决这个问题,不需要用ssl黑客来妥协安全性

其他回答

构造变压器失败:错误:错误:0308010C:数字信封例程::不支持

解决上述错误的最简单和最简单的解决方案是将Node.js降级到v14.18.1。然后只需删除文件夹node_modules,并尝试重新构建项目,您的错误必须解决。

如果遇到此错误,并且不想更改主配置,则可以使用以下方法进行简单的修复。不过,我不确定这是否被推荐为一种好的做法。

请随意改正。

最初,假设这是我的包的脚本部分。json文件:

...
"version": "1.0.0",
  "scripts": {
    ...
    "build": "npm run build:test-app:testing",
    "build:test-app:testing": "ng build test-app --deploy-url  https://test-app.com/ --configuration=test-config",
    ...
  },
  "private": true,
...

为了使用这个导出NODE_OPTIONS=——openssl-legacy-provider,您可以执行以下操作:

"version": "1.0.0",
  "scripts": {
....
    "build": "NODE_OPTIONS=--openssl-legacy-provider npm run build:test-app:testing”,
    "build:test-app:testing": "NODE_OPTIONS=--openssl-legacy-provider ng build test-app --deploy-url  https://test-app.com/ --configuration=test-config"
...
  },
  "private": true,

注意构建脚本。我添加了一个选项:NODE_OPTIONS=——openssl-legacy-provider

这有助于在Node.js version 17中解决此错误。

对于那些可以灵活更改构建系统的Node.js版本的人,只需切换到低于17的版本,例如,版本16。

对于Docker,最初使用this的用例,它总是提取最新版本:

...
FROM node:alpine
...

你可以切换到如下内容:

...
FROM node:16-alpine3.12
...

我在vue js项目中也遇到了同样的问题。我所做的是从机器上卸载node js的新版本(>18),并安装以前的版本(v16.14.2)。它的工作原理

有很多变通办法(主要是降级Node.js, OpenSSL,或允许不安全的散列),但潜在的问题是Webpack的输出。hashFunction默认为md4,这会在最新版本的OpenSSL中触发此错误。

从Webpack的输出。hashFunction文档:

从Webpack v5.54.0+开始,hashFunction支持xxhash64作为一种更快的算法,当 实验。futureDefaults已启用。

解决方案是:

设置输出。hashFunction = 'xxhash64' 设置实验。futureDefaults = true

在Webpack配置中。

如果您使用的是较旧版本的Webpack(在v5.54.0之前),请遵循输出。hashFunction链接可以查看其他可用的哈希算法。

“快速修复”的建议对我很有效。cd到你新建的App目录;您可能需要sudo这个安装,然后运行以下:

运行: NPM install -g NPM -check-updates

然后: 中央大学- u

然后: npm安装

然后: npm开始