Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

could not start on replit #45

Open
fanesz opened this issue Oct 12, 2021 · 19 comments
Open

could not start on replit #45

fanesz opened this issue Oct 12, 2021 · 19 comments
Labels
good first issue Good for newcomers

Comments

@fanesz
Copy link

fanesz commented Oct 12, 2021

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?

@KagChi
Copy link
Owner

KagChi commented Oct 12, 2021

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

@fanesz
Copy link
Author

fanesz commented Oct 12, 2021

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

@KagChi
Copy link
Owner

KagChi commented Oct 12, 2021

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

@fanesz
Copy link
Author

fanesz commented Oct 12, 2021

it says :

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

@KagChi
Copy link
Owner

KagChi commented Oct 12, 2021

in your main.js file duh, basic js.

@fanesz
Copy link
Author

fanesz commented Oct 12, 2021

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)

@KagChi
Copy link
Owner

KagChi commented Oct 12, 2021

does it log your token

@fanesz
Copy link
Author

fanesz commented Oct 12, 2021

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

@fanesz
Copy link
Author

fanesz commented Oct 12, 2021

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

@KagChi
Copy link
Owner

KagChi commented Oct 12, 2021

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 KagChi added bug Something isn't working question Further information is requested labels Oct 12, 2021
@KagChi KagChi changed the title replit could not start on replit Oct 12, 2021
@fanesz
Copy link
Author

fanesz commented Oct 13, 2021

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?

@KagChi
Copy link
Owner

KagChi commented Oct 13, 2021

image
are you inputed environment like this?

@fanesz
Copy link
Author

fanesz commented Oct 13, 2021

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

@fanesz
Copy link
Author

fanesz commented Oct 13, 2021

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 ^^

@KagChi
Copy link
Owner

KagChi commented Oct 13, 2021

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

@KagChi KagChi added good first issue Good for newcomers and removed bug Something isn't working question Further information is requested labels Oct 13, 2021
@KagChi KagChi pinned this issue Oct 18, 2021
@KagChi KagChi linked a pull request Mar 14, 2022 that will close this issue
@Boggles1288
Copy link

Boggles1288 commented Jun 17, 2022

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`

@UnknownLITE
Copy link

UnknownLITE commented Jul 5, 2022

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]

@KagChi
Copy link
Owner

KagChi commented Jul 5, 2022

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.

@UnknownLITE
Copy link

I'm talking about Replit Secrets
This 👇
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants