Missing jwtSecret when I want to deploy production environment

System Information
  • Strapi Version: 4.8.2
  • Operating System: Windows
  • Database: Mysql
  • Node Version: v14.20.0
  • NPM Version: 6.14.17
  • Yarn Version: 1.22.19

The problem occurred when I was trying to deploy a staging environment and noticed this issue on startup.(I‘m sorry that my English is not good. Forgive me if I didn’t phrase it very clearly. ’)

The command I use:
$env:NODE_ENV=“production”
yarn start

The error message is as follows:

debug: ⛔️ Server wasn't able to start properly.
error: Missing jwtSecret. Please, set configuration variable "jwtSecret" for the users-permissions plugin in config/plugins.js (ex: you can generate one using Node with `crypto.randomBytes(16).toString('base64')`).
For security reasons, prefer storing the secret in an environment variable and read it in config/plugins.js. See https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.html#configuration-using-environment-variables.

My structure:
image

The file: /config/env/production/database.js

The file: .env

Can you guys help me please.Thank you very much.

Missing information:
The file:/config/plugins.js

Small tip don’t post the actual keys that you have in your screenshot.
The JWT is been read from /config/env/XXX/admin.js or /config/admin.js

Remember your .env is not committed so you need to SET those variables on the server or in the container. Else they don’t exists and you will have the error you are getting.

Thank you for advice. This is the first time I’ve asked a question in this community and I appreciate you guys getting back to me so quickly.I’ll try following your advice back.

Hello,
Did you find a fix for your problem? I have the same issue.