I have problem launching bot on the server with forever...
I'm using process.env
where I store BOT Token and Instagram login credentials.
However on the server i cannot made bot work due this error..
(node:30365) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
ig-bot/node_modules/discord.js/src/client/Client.js:228
if (!token || typeof token !== 'string') throw new Error('TOKEN_INVALID');
^
Error [TOKEN_INVALID]: An invalid token was provided.
at Client.login (ig-bot/node_modules/discord.js/src/client/Client.js:228:52)
at Object.<anonymous> (ig-bot/ig.js:64:8)
at Module._compile (node:internal/modules/cjs/loader:1092:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
at Module.load (node:internal/modules/cjs/loader:972:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47 {
[Symbol(code)]: 'TOKEN_INVALID'
}
error: Forever detected script exited with code: 1
error: Script restart attempt #1
ig-bot/node_modules/discord.js/src/client/Client.js:228
if (!token || typeof token !== 'string') throw new Error('TOKEN_INVALID');
^
Error [TOKEN_INVALID]: An invalid token was provided.
at Client.login (ig-bot/node_modules/discord.js/src/client/Client.js:228:52)
at Object.<anonymous> (ig-bot/ig.js:64:8)
at Module._compile (node:internal/modules/cjs/loader:1092:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
at Module.load (node:internal/modules/cjs/loader:972:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47 {
[Symbol(code)]: 'TOKEN_INVALID'
}
error: Forever detected script exited with code: 1
It says token is invalid, but it really does not make any sense because it works on my PC and i can run the code via visual studio without problem. Same folder of the bot has trouble running on my server (usually i use config.json for token, but this time i need .env file)
//Process ENV code
const dotenv = require('dotenv');
dotenv.config({ path: './process.env' });
const username = process.env.IGUSERNAME
const password = process.env.IGPASSWORD
const TOKEN = process.env.TOKEN
client.login(TOKEN);
I tried ENV=production forever start yourApp.js
forever -c "node -r dotenv/config" --workingDir app-workdir-path start app.js
but none of these worked for me...