解決 Nodejs 18 中的 "Error: error:0308010C:digital envelope routines::unsupported" 錯誤的方法
P粉121081658
P粉121081658 2023-10-18 15:53:45
0
2
786

我的 NuxtJS 應用程式需要幫助。

最近,在我離開應用程式一段時間(2 個月)而沒有更新後,應用程式中出現了 ESLint 衝突。因此,在我開始研究它之後,嘗試解決 ESLint 問題提出了挑戰。然後我必須將專案遷移到較新版本的 Node 和 ESLint。

這樣做之後,我解決了衝突問題,我的專案可以安裝我的依賴項,但現在伺服器無法啟動。節點現在拋出一個錯誤,我什至不知道如何修復。我不知道許多其他人在升級 Node.js 版本後是否面臨這個問題,但它拋出了有關不支援的哈希函數的錯誤。

這是阻止我的伺服器啟動的終端錯誤的螢幕截圖:

我已經解決了遷移帶來的所有 ESLint 和語法錯誤,所以我不知道還能做什麼。

下面是我的 nuxt.config.js 檔案的片段:

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"]
  },
}


#
P粉121081658
P粉121081658

全部回覆(2)
P粉044526217

就我而言,當我執行 npm run build 時,這發生在我的 Github Actions 建置管道中。

我能夠透過提供以下環境參數來修復它:

export NODE_OPTIONS=--openssl-legacy-provider

根據我所讀到的內容,這個節點選項也可以在 package.json 中設定。

這似乎比將 Nodejs 降級到 v16 容易一些。

P粉090087228

關於這個錯誤,經過大量研究後,我終於發現整個錯誤是在nodejs升級到v18.12.1版本時出現的,所以我建議所有遇到同樣問題的最近剛剛升級tio node v18.12.1的人降級回到節點v16.0.0,如果您需要這方面的協助,您可以使用nvm

下面概述了一些步驟,以及一些資源連結

`

  1. 下載並安裝 nvm 按照此處的說明進行操作
  1. #安裝 Nodejs v16.0.0 nvm安裝16.0.0

  2. 卸載nodejs v18.12.1 nvm uninstall 18.12.1 或您自己的節點版本

我確實這對某人有幫助,就像對我一樣,我知道框架錯誤帶來的痛苦。如果您需要進一步協助,請發表評論。 謝謝。

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!