【问题标题】:How to resolve "Error: error:0308010C:digital envelope routines::unsupported" Nodejs 18 error如何解决 \"Error: error:0308010C:digital envelope routines::unsupported\" Nodejs 18 错误
【发布时间】:2023-01-26 06:18:10
【问题描述】:

我的 nuxtjs 应用程序需要帮助。 我最近在应用程序中遇到了 eslint 冲突,因为我离开了一段时间而没有更新(2 个月)。因此,在我开始开发该应用程序后,它发布了试图解决 eslint 问题的挑战,因此我不得不将项目迁移到更新版本的节点和 eslint。在做儿子之后我解决了冲突问题并且我的项目可以安装我的依赖项,但是现在服务器无法启动,节点现在抛出一个错误我什至不知道如何开始修复,我不知道是否有很多其他人面临这个问题升级他们的 nodejs 版本后出现问题,但它抛出一个关于不受支持的哈希函数的错误。

这是阻止我的服务器启动的终端错误的屏幕截图,我已经解决了迁移带来的所有 eslint 和语法错误,所以我不知道还能做什么。我真的需要帮助。

下面是我的 nuxt.config.js 文件的 sn-p

export default {
  // Global page headers: https://go.nuxtjs.dev/config-head
  head: {
    title: 'heritage-fd',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' },
      { name: 'format-detection', content: 'telephone=no' }
    ],
    
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ],
    
    script: [
      {
        src: '~/static/css/bootstrap.min.js',
      },
    ],
  },

  // Global CSS: https://go.nuxtjs.dev/config-css
  css: [
    {src: '~/static/css/bootstrap.min.css', lang: 'scss'},
    {src: '~/assets/scss/custom.scss', lang: 'scss'},
    {src: "~layouts/global.css"},
    {src: '~/static/css/style.css', lang: 'scss'},
    {src: '~/assets/css/main.css'}
    
  ],

  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
   plugins: [
    "~/plugins/vee-validate.js",
    { src: '~/plugins/persistedState.client.js', ssr: false }
   ],

  // Auto import components: https://go.nuxtjs.dev/config-components
  components: true,

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [
    // https://go.nuxtjs.dev/eslint
    '@nuxtjs/eslint-module',
    'nuxt-gsap-module',
    '@nuxtjs/fontawesome',
  ],

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: [
    // https://go.nuxtjs.dev/axios
    '@nuxtjs/axios',
    // https://go.nuxtjs.dev/pwa
    '@nuxtjs/pwa',
    '@nuxtjs/auth-next',
    'nuxt-vue-select'
  ],

  // Axios module configuration: https://go.nuxtjs.dev/config-axios
  axios: {
    // Workaround to avoid enforcing hard-coded localhost:3000: https://github.com/nuxt-community/axios-module/issues/308
    baseURL: 'http://localhost:8000/api/',
    
  },

  // PWA module configuration: https://go.nuxtjs.dev/pwa
   pwa: {
    manifest: {
      lang: 'en',
    },
  },

  // Build Configuration: https://go.nuxtjs.dev/config-build
 build: {
    transpile: ["vee-validate/dist/rules"],
    vendor: ["vue-tables-2"]
  },
}

【问题讨论】:

  • 您是否尝试删除您的node_modules,重新安装 yarn/pnpm 以检查一些错误?另外,前后有package.json吗?介意也共享nuxt.config.js 文件吗?
  • 是的,我做到了,是的,我将分享我的 nuxt 配置文件
  • 剩下的呢?
  • 不删除 node_modules 不能解决问题,@kissu 什么测试?你指的是,那是我的整个 nuxt.config 文件。

标签: javascript node.js vue.js frontend nuxt.js


【解决方案1】:

关于这个错误,在做了很多研究之后,我终于发现整个错误都伴随着nodejs升级到v18.12.1版本,所以我建议所有面临同样问题的人最近升级tio node v18.12.1降级回node v16.0.0,如果你需要帮助,你可以使用nvm

下面概述了一些步骤,并提供了一些资源链接

`

  1. 下载并安装 nvm Follow instructions here
    1. 安装 Node.js v16.0.0 nvm install 16.0.0

    2. 卸载 nodejs v18.12.1 nvm uninstall 18.12.1 或您自己的节点版本

    我真的这对别人有帮助,就像对我一样,我知道框架错误带来的痛苦。如果您需要进一步的帮助,请发表评论。 谢谢你。

【讨论】:

  • 为我工作。在 Windows 上,您只需像往常一样卸载 node.js 18,然后下载/安装 16。
  • 在执行此操作之前,请考虑此 - stackoverflow.com/a/73027407/1459653 - 中的警告。
  • 那不是解决办法。您需要升级使用过时 SSL 的过时库,而不是相反。在我的例子中,它是一个旧版本的 webpack。 @MarkGavagan 评论有描述正确解决方案的链接。
  • 将 Node 降级到 < 17 它对我有用;我在用反应脚本”:“^ 4.0.0”;但在看到@MarkGavagan 评论后,我做了一个npm audit fix --force 并升级了我的反应脚本”:“^ 5.0.1”.在那之后,SSL 问题就解决了,现在可以在 Node > 17 上使用了。
【解决方案2】:

查看这里的解决方案,我决定在项目中安装 node@16.0.0 作为开发依赖。

npm install node@16.0.0 --save-dev

然后在脚本中包含命令“dev”:“npm run serve”。

"scripts": {
    "dev": "npm run serve",
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
},

这将使它在你运行命令“npm run dev”时

npm run dev

它将使用项目依赖项的节点运行脚本。

【讨论】:

    【解决方案3】:

    你可以选择给出的答案浪漫的阿卡姆,但是如果你有多个项目需要不同的节点版本(在我的例子中我有两个依赖于不同版本的项目)

    因此,在这种情况下,无论您遇到此问题,都转到项目目录并运行nvm install 16.0.0

    注意:请先安装nvm

    【讨论】:

      【解决方案4】:

      我注意到有一个更新的版本:节点 18.13.0.所以我尝试更新到这个最新版本而不是回滚到以前的版本,但它没有用。

      然后,我在这里查看了其他版本:

      https://nodejs.org/dist/

      安装版本 Node-v15.6.0 在我这边解决了这个问题。因此,目前回滚 Node 可能是我们最好的选择。

      【讨论】:

        猜你喜欢
        • 2022-11-13
        • 2023-01-25
        • 2023-02-13
        • 2022-12-15
        • 2023-01-24
        • 2022-11-08
        • 2022-12-28
        • 2021-10-26
        • 2018-08-05
        相关资源
        最近更新 更多