noteblock icon indicating copy to clipboard operation
noteblock copied to clipboard

could not start on replit

Open fanesz opened this issue 4 years ago • 19 comments

i can't run in replit, it always says [Symbol(code)]: 'TOKEN_INVALID'] because i can't rename .env.scheme to .env how to solve it?

fanesz avatar Oct 12 '21 13:10 fanesz

replit introduce new way to fill .env file, its now on environtment tab

KagChi avatar Oct 12 '21 14:10 KagChi

i just did that, but it still show this

[2021-10-12T14:07:38.291] [INFO] NOTEBLOCK - [REPLIT ENVIRONMENT DETECTED] [STARTING WEBSERVER]
/home/runner/noteblock-2/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 NoteClient.login (/home/runner/noteblock-2/node_modules/discord.js/src/client/Client.js:228:52)
    at NoteClient.initialize (/home/runner/noteblock-2/src/Struct/NoteClient.js:75:10)
    at Object.<anonymous> (/home/runner/noteblock-2/src/index.js:6:8)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at initialize (/home/runner/noteblock-2/src/main.js:25:12) {
  [Symbol(code)]: 'TOKEN_INVALID'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `bash start.sh`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2021-10-12T14_07_39_392Z-debug.log
exit status 1

what i did :

  1. import from github
  2. input owner id at index.js
  3. make .env on environtment tab
  4. run

fanesz avatar Oct 12 '21 14:10 fanesz

does it log your token if do console.log(process.env.DISCORD_TOKEN) ?, aslo dont copy the client secret one

KagChi avatar Oct 12 '21 14:10 KagChi

it says :

console.log(process.env.DISCORD_TOKEN)
bash: syntax error near unexpected token `process.env.DISCORD_TOKEN'

fanesz avatar Oct 12 '21 14:10 fanesz

in your main.js file duh, basic js.

KagChi avatar Oct 12 '21 14:10 KagChi

sorry im new, i try to put console.log(process.env.DISCORD_TOKEN) in src/main.js but still says the same error (i've tried put it at the first line, middle line, and last line)

fanesz avatar Oct 12 '21 14:10 fanesz

does it log your token

KagChi avatar Oct 12 '21 14:10 KagChi

no, i didn't see any token when i run with that thing in my main.js still show same error

fanesz avatar Oct 12 '21 14:10 fanesz

also i've try self hosting it, and work perfectly. So i think the problem is with replit.

fanesz avatar Oct 12 '21 14:10 fanesz

also i've try self hosting it, and work perfectly. So i think the problem is with replit.

Maybe you wrongly place the cofiguration in environment

KagChi avatar Oct 12 '21 17:10 KagChi

i just host it at HEROKU.com and work perfectly, but i still want host it at replit because heroku have limit usage.

is that any command for .replit file to read and run inside the code folder? so i can bash start.sh along with .env file in the same folder? like : (inside .replit)

cd noteblock
run="npm run"

or maybe can i move .env file inside any folder and main.js still can read it?

fanesz avatar Oct 13 '21 00:10 fanesz

image are you inputed environment like this?

KagChi avatar Oct 13 '21 00:10 KagChi

yes, i input : key -> .env value -> DISCORD_TOKEN=xxxx

fanesz avatar Oct 13 '21 00:10 fanesz

SOLVED

so i just do npm install after cloning, then make .env with the things inside src folder then in main.js i change from : require('dotenv').config(); to

const path = require('path')
require('dotenv').config({ path: path.resolve(__dirname, '.env') })

and it work prefectly ^^

fanesz avatar Oct 13 '21 02:10 fanesz

thanks for resolving, current issue. gonna add to the code soon

KagChi avatar Oct 13 '21 02:10 KagChi

THis still doesn't work, please help, I'm a bit rusty to this. I did everything you guys said and I got this error:

`[2022-06-17T07:42:45.419] [INFO] NOTEBLOCK - [REPLIT ENVIRONMENT DETECTED] [STARTING WEBSERVER] /home/runner/noteblock/node_modules/discord.js/src/client/Client.js:237 if (!token || typeof token !== 'string') throw new Error('TOKEN_INVALID'); ^

Error [TOKEN_INVALID]: An invalid token was provided.  npm start

[email protected] start /home/runner/noteblock bash start.sh

npm WARN lifecycle The node binary used for scripts is /usr/bin/node but npm is using /home/runner/noteblock/node_modules/node/bin/node itself. Use the --scripts-prepend-node-path option to include the path for the node binary npm was executed with.

[email protected] preinstall /home/runner/noteblock/node_modules/node node installArchSpecificPackage

65 packages are looking for funding run npm fund for details

found 0 vulnerabilities

[2022-06-17T07:43:21.975] [INFO] NOTEBLOCK - [REPLIT ENVIRONMENT DETECTED] [STARTING WEBSERVER] /home/runner/noteblock/node_modules/discord.js/src/client/Client.js:237 if (!token || typeof token !== 'string') throw new Error('TOKEN_INVALID'); ^

Error [TOKEN_INVALID]: An invalid token was provided. at NoteClient.login (/home/runner/noteblock/node_modules/discord.js/src/client/Client.js:237:52) at NoteClient.initialize (/home/runner/noteblock/src/Struct/NoteClient.js:75:10) at Object. (/home/runner/noteblock/src/index.js:7:8) at Module._compile (node:internal/modules/cjs/loader:1103:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at initialize (/home/runner/noteblock/src/main.js:26:12) { [Symbol(code)]: 'TOKEN_INVALID' } npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] start: bash start.sh npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /home/runner/.npm/_logs/2022-06-17T07_43_24_237Z-debug.log exit status 1`

Boggles1288 avatar Jun 17 '22 07:06 Boggles1288

yes, i input : key -> .env value -> DISCORD_TOKEN=xxxx

Nope, you did it wrong, This is what should be (according to this repo) key=DISCORD_TOKEN, value=[insert_your_bot_token_here]

UnknownLITE avatar Jul 05 '22 12:07 UnknownLITE

yes, i input : key -> .env value -> DISCORD_TOKEN=xxxx

Nope, you did it wrong, This is what should be (according to this repo) key=DISCORD_TOKEN, value=****

this is not valid.

env should be DISCORD_TOKEN=TOKEN DISCORD_TOKEN is your key, and token is your value.

KagChi avatar Jul 05 '22 12:07 KagChi

I'm talking about Replit Secrets This 👇 image

UnknownLITE avatar Jul 05 '22 12:07 UnknownLITE