我的 NuxtJS 應(yīng)用程序需要幫助。
最近,在我離開應(yīng)用程序一段時(shí)間(2 個(gè)月)而沒有更新后,應(yīng)用程序中出現(xiàn)了 ESLint 沖突。因此,在我開始研究它之后,嘗試解決 ESLint 問題提出了挑戰(zhàn)。然后我必須將項(xiàng)目遷移到較新版本的 Node 和 ESLint。
這樣做之后,我解決了沖突問題,我的項(xiàng)目可以安裝我的依賴項(xiàng),但現(xiàn)在服務(wù)器無法啟動。節(jié)點(diǎn)現(xiàn)在拋出一個(gè)錯誤,我什至不知道如何修復(fù)。我不知道許多其他人在升級 Node.js 版本后是否面臨這個(gè)問題,但它拋出了有關(guān)不支持的哈希函數(shù)的錯誤。
這是阻止我的服務(wù)器啟動的終端錯誤的屏幕截圖:
我已經(jīng)解決了遷移帶來的所有 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"] }, }
就我而言,當(dāng)我運(yùn)行 npm run build
時(shí),這發(fā)生在我的 Github Actions 構(gòu)建管道中。
我能夠通過提供以下環(huán)境參數(shù)來修復(fù)它:
export NODE_OPTIONS=--openssl-legacy-provider
根據(jù)我所讀到的內(nèi)容,這個(gè)節(jié)點(diǎn)選項(xiàng)也可以在 package.json 中設(shè)置。
這似乎比將 Nodejs 降級到 v16 容易一些。
關(guān)于這個(gè)錯誤,經(jīng)過大量研究后,我終于發(fā)現(xiàn)整個(gè)錯誤是在nodejs升級到v18.12.1版本時(shí)出現(xiàn)的,所以我建議所有遇到同樣問題的最近剛剛升級tio node v18.12.1的人降級回到節(jié)點(diǎn) v16.0.0,如果您需要這方面的幫助,您可以使用 nvm
。
下面概述了一些步驟,以及一些資源鏈接
`
安裝 Nodejs v16.0.0
nvm安裝16.0.0
卸載nodejs v18.12.1
nvm uninstall 18.12.1
或您自己的節(jié)點(diǎn)版本
我確實(shí)這對某人有幫助,就像對我一樣,我知道框架錯誤帶來的痛苦。如果您需要進(jìn)一步幫助,請發(fā)表評論。 謝謝。