Ask coding questions

← Back to all posts
Discord Token node.js
NightmareTaken

How do I take my discord bot token from a .env file and use it in another file without just copy and pasting it(node.js)

Voters
LustW
NightmareTaken
Comments
hotnewtop
Coder100
Coder100

process.env.TOKEN

WWEMONSTERMONST

To get a variable from .env file:
1) goto shell and do npm init -y (or repl will perform this step automatically when you execute the code in step 3)
2) goto shell and do npm install dotenv (same as step 1)
3)

and this will do it!