error giving npm start at command prompt

Asked

Viewed 76 times

-1

i am starting now with js , and decided to make a bot for Discord servers, as I use the platform a lot. I started watching tutorials, and I made my first bot hosting on Repl.it, as I didn’t really like the site, and most of the examples and tutorials are by vs code, I decided to try to do one by vs code, so I started by following the tutorial and adding Discord.js to my project, following the steps of the tutorial I tried to start npm in my bot folder, and gave an error, follow the error and print of the error: (Node:17552) Unhandledpromiserejectionwarning: Error: An invalid token was provided. AT: Users Youtu Documents Sounnybot node_modules Discord.js src client Rest Restmethods.js:36:54 at new Promise () at Restmethods.login (C: Users Youtu Documents Sounnybot node_modules Discord.js src client Rest Restmethods.js:35:12) At client.login (C: Users Youtu Documents Sounnybot node_modules Discord.js src client Client.js:280:30) At object. (C: Users Youtu Documents Sounnybot core.js:15:8) At module. _Compile (Internal/modules/cjs/Loader.js:1063:30) At object.Module. _Extensions.. js (Internal/modules/cjs/Loader.js:1092:10) At module.load (Internal/modules/cjs/Loader.js:928:32) At function.Module. _load (Internal/modules/cjs/Loader.js:769:14) At function.executeUserEntryPoint [as runMain] (Internal/modules/run_main.js:72:12) (Use node --trace-warnings ... to show Where the Warning was created) (Ode:17552) Unhandledpromiserejectionwarning: Unhandled Promise rejection. This error either originated by Throwing Inside of an async Function without a catch block, or by rejecting a Promise which was not handled with . (catch). To terminate the Node process on unhandled Promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3) (Ode:17552) [DEP0018] Deprecationwarning: Unhandled Promise rejections are deprecated. In the Future, Promise rejections that are not handled will terminate the Node.js process with a non-zero Exit code. segue imagem caso não tenha entendido

and my script folder is only with: "test": "echo "Error: no test specified" && Exit 1", "start": "Node core" as I just started the project has virtually nothing on it.

  • Tried to spin a npm install ?

  • yes, but it was not, it already excludes node_modules and package-lock.json and dei npm update , install , but nn will

1 answer

0

The mistake says that the token provided access is wrong and this could probably be solved with a block Try/catch. If you have any Promise in your code try to exchange the token (which is given on the site of the chosen api). If you do not use Prefixes or Apis.Place a Try/catch block like this:

function yourFunction(yourParams){
   try{
       //Your code
   }catch(error){ 
       console.log(error)
   }
}

  • hello, good evening, so as I mentioned above I am beginner, and am following step of tutorials, so could you tell me where I put this codiogo, in which folder or right? Thanks for the comment!

  • You could send the code github or a photo of the folders it has. So you would know better guide you. But at first you will put the code snippet that I passed you in some function where you access some kind of Token,a code that some site passed you probably Discord

Browser other questions tagged

You are not signed in. Login or sign up in order to post.