错误:错误:0308010C:数字信封例程::不支持

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

我已经尝试将 nuxt 应用程序部署到 Vercel 几天了,但我收到此错误消息:

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

我在本地计算机上解决了这个问题,将我的node.js降级到16+,但在生产环境中仍然出现这种情况。我尝试将 --openssl-legacy-provider 设置为 package.json 中的脚本对象,但没有效果。附:我不太确定语法是否正确,因为大多数答案都是针对反应的。

这是整个错误:

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (/vercel/path0/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/vercel/path0/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/vercel/path0/node_modules/webpack/lib/NormalModule.js:471:10)
    at /vercel/path0/node_modules/webpack/lib/NormalModule.js:503:5
    at /vercel/path0/node_modules/webpack/lib/NormalModule.js:358:12
    at /vercel/path0/node_modules/webpack/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/vercel/path0/node_modules/webpack/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at Array.<anonymous> (/vercel/path0/node_modules/webpack/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
    at Storage.finished (/vercel/path0/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
    at /vercel/path0/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
    at /vercel/path0/node_modules/graceful-fs/graceful-fs.js:123:16
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}
Node.js v18.12.1
Error: Command failed with exit code 1: npx nuxt build --standalone --no-lock --config-file "nuxt.config.js" /vercel/path0

我的package.json:

{
  "name": "my-project",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate"
  },
  "dependencies": {
    "@nuxtjs/axios": "^5.13.6",
    "@nuxtjs/vercel-builder": "^0.24.0",
    "@nuxtjs/vuetify": "^1.12.3",
    "@stripe/stripe-js": "^1.46.0",
    "cookie-parser": "^1.4.6",
    "cookieparser": "^0.1.0",
    "cors": "^2.8.5",
    "express": "^4.18.2",
    "gsap": "npm:@gsap/shockingly@^3.11.3",
    "nuxt": "^2.14.6",
    "nuxt-gsap-module": "^1.7.2",
    "stripe": "^11.3.0",
    "vuex-persistedstate": "^4.1.0"
  }
}
node.js nuxt.js vercel
7个回答
18
投票

我通过在 package.json 中定义 node.js 版本来让它工作,如下所示:

"engines": {
  "node": "16.x"
},

10
投票

运行此命令来解决问题:

export NODE_OPTIONS=--openssl-legacy-provider

4
投票

我遇到了同样的错误,以下解决方案对我有用:

您可以在项目的根级别执行此命令,或者只需打开终端并运行。

set NODE_OPTIONS=--openssl-legacy-provider

之前:

之后


2
投票

我遇到了同样的问题,我通过这样做解决了它: 在你的 pakage.json 文件中放入这两行 然后你的错误就会得到解决。

"scripts": {
"start": "react-scripts --openssl-legacy-provider start",
"build": "react-scripts --openssl-legacy-provider build",
}

1
投票

我解决了这个问题,在

package.json
中添加此选项:

"engines": {
  "node": "18.x"
},

"scripts": {
  "start": "react-scripts --openssl-legacy-provider start",
  "build": "react-scripts --openssl-legacy-provider build",
}

0
投票

我所做的是将package.json中的react-script更新为5.0.0,删除package.lock.json和node_modules,然后在终端中执行npm install。

来源:https://www.freecodecamp.org/news/error-error-0308010c-digital-envelope-routines-unsupported-node-error-solved/


0
投票

//这个解决方案可行 //webpack.config.js

const path = require("path");
const crypto = require("crypto");
const crypto_orig_createHash = crypto.createHash;
crypto.createHash = algorithm => crypto_orig_createHash(algorithm == "md4" ? "sha256" : algorithm);

module.exports = {
  entry: "./src/index.js",
  output: {
    filename: "app.js",
    hashFunction: "sha256",
    path: path.resolve(__dirname, "dist")
  },
  devServer: {
    contentBase: path.join(__dirname, "dist"),
    port: 9000
  },
  mode: "development"
};
© www.soinside.com 2019 - 2024. All rights reserved.