Romanric Akam
Romanric Akam

Reputation: 1109

How to resolve "Error: error:0308010C:digital envelope routines::unsupported" Nodejs 18 error

I need help with my NuxtJS application.

I recently had ESLint conflicts in the app after I left it for some time without updating (2 months). So after I started working on it, it presented a challenge trying to resolve the ESLint issue. I then had to migrate the project to a newer version of Node and ESLint.

After doing this, I solved the conflict issue and my project could install my dependencies, but now the server won't start. Node is now throwing an error that I don't even know how to fix. I don't know if many others are facing this issue after upgrading their versions of Node.js, but it's throwing an error about an unsupported hash function.

Here is a screenshot of the terminal error that is preventing my server from starting up:

Node error, server won't start

I have resolved all ESLint and syntax errors that came with the migration, so I don't know what else to do.

Below is a snippet of my nuxt.config.js file:

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

Upvotes: 44

Views: 170027

Answers (5)

finisinfinitatis
finisinfinitatis

Reputation: 1639

In my case this happened in my Github Actions build pipeline when I was running npm run build.

I was able to fix it by providing the following environment argument:

export NODE_OPTIONS=--openssl-legacy-provider

According from what I have read this node option can also be set in package.json.

What I did was modifying the scripts section of my package.json:

"scripts": {
  "ng": "set NODE_OPTIONS=--openssl-legacy-provider && ng",
  "start": "set NODE_OPTIONS=--openssl-legacy-provider && ng serve",
  "build": "ng build",
  "test": "ng test",
  "lint": "ng lint",
  "e2e": "ng e2e"
},

Now I can run npm start again without problems.

This seems a bit easier than downgrading nodejs to v16.

Upvotes: 79

Erik Khasanov
Erik Khasanov

Reputation: 111

I spent a lot of time solving the problem. If you are using Fedora and you get this error

try run your project with flag: NODE_OPTIONS=--openssl-legacy-provider example: "dev": "NODE_OPTIONS=--openssl-legacy-provider next -p 4000"

If it helped you, then you can set it to Node environments

  • check your options in console echo $NODE_OPTIONS
  • if options is empty, set it export NODE_OPTIONS=--openssl-legacy-provider

I use 16.17.1 version of NodeJs, set NODE_OPTIONS var helped me.

If this does not help, then try the last step, try to uncomment the following lines in your /etc/ssl/openssl.cnf file.

Upvotes: 11

Gustavo Hilario
Gustavo Hilario

Reputation: 7

I noticed there was a newer version: Node-18.13.0. So I tried to update to this latest version instead of rolling back to a previous version, but it didn't work.

Then, I checked out other versions here:

https://nodejs.org/dist/

Installing version Node-v15.6.0 fixed this issue on my end. So, rolling back Node, for now, might be our best option.

Upvotes: -2

Michel
Michel

Reputation: 335

Checking the solutions here, I decided to install [email protected] as a development dependency in the project.

npm install [email protected] --save-dev

Then include in the scripts the command "dev": "npm run serve".

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

This will make it so that when you run the command "npm run dev"

npm run dev

it will run the script using the node of your project's dependencies.

Upvotes: 19

Romanric Akam
Romanric Akam

Reputation: 1109

Concerning this error, after doing some much research, i finally discovered that the whole error comes with the nodejs upgrade to version v18.12.1, so i advice everyone facing this same issue who just recently upgraded tio node v18.12.1 to downgrade back to node v16.0.0, if u need help with this , you can use nvm.

some steps are outlined below, with some link to resources

`

  1. Download and install nvm Follow instructions here
  1. Install Nodejs v16.0.0 nvm install 16.0.0

  2. Uninstall nodejs v18.12.1 nvm uninstall 18.12.1 or your own version of node

I truly this helps someone as it did for me, I know the pains that come with framework errors. Please comment if you need further assistance. thank you.

Upvotes: 46

Related Questions