accessing .env file unseccessfully in node.js

  Kiến thức lập trình

I was working on a discord chatbot for some practice and try to access some environment variable in .env file. However , some how I was not able to access those variables with some following code:

const dotenv = require('dotenv');

dotenv.config();

console.log(process.env.A);
console.log(process.env.B);
console.log(process.env.DISCORD_TOKEN);
A="123"
B="456"
DISCORD_TOKEN="some-token"

My Directory

When I run these code , I found that they cannot be accessed and point to a node module call process

The variable pointed

Output(not expected)

Finally , thanks for everybody’s help since I am a very beginner for some API project like this.

LEAVE A COMMENT