'Verify JWT Token error 'secretOrPrivateKey must have a value'

return failure(new Error('secretOrPrivateKey must have a value'));enter image description here



Solution 1:[1]

I think your application is not able to read the environnement variables.

I advice you to use the package dotenv : https://github.com/motdotla/dotenv

After installing it you have to import it at the top of your application like this:

require("dotenv").config();

Specify a file .env at the root of your application and add your variables

JWT_SECRET=12bob12ou2b1ob
NODE_ENV=development

After, you can use the variables like you did in your linked image:

const jwtSecret = process.env.JWT_SECRET

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jackmekiss