Unexpected token {

/rbd/pnpm-volume/2bb7b019-fb1d-4096-b9c0-4034cac1c560/node_modules/.registry.npmjs.org/discord.js/12.0.1/node_modules/discord.js/src/client/Client.js:40

} catch {

        ^

SyntaxError: Unexpected token {

at createScript (vm.js:80:10)

at Object.runInThisContext (vm.js:139:10)

at Module._compile (module.js:617:28)

at Object.Module._extensions..js (module.js:664:10)

at Module.load (module.js:566:32)

at tryModuleLoad (module.js:506:12)

at Function.Module._load (module.js:498:3)

at Module.require (module.js:597:17)

at require (internal/module.js:11:18)

at Object.<anonymous> (/rbd/pnpm-volume/2bb7b019-fb1d-4096-b9c0-4034cac1c560/node_modules/.registry.npmjs.org/discord.js/12.0.1/node_modules/discord.js/src/index.js:8:11)

// Obtain shard details from environment or if present, worker threads
let data = process.env;
try {
// Test if worker threads module is present and used
data = require(‘worker_threads’).workerData || data;
} catch {
// Do nothing
}

this bit of code in Client.js seems to be the problem, any help?
edit: resolved! rewinded my project

same thing is happening to me

Hello @very-interestin-g,

the code you’ve posted has an error at the catch statement. for it to work, you need to catch the error object from the try block. Working code looks like this:

} catch (error) {
// Do nothing
}

Hope this helps!

It looks like I was wrong- this error is happening because your version of Node.js is out of date. In package.json, make sure you have the correct node version:

  "engines": {
    "node": "12.x"
  },

alright thank you though

This is correct, discord.js recently released v12, and v12 uses statements only usable in Node.js v12

1 Like

How to upgrade or download node v12.