Discord.js error


hi all

trying to make a bot for discord with node.js i have got this error running my script:

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions…js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (/home/ubuntu/workspace/node_modules/discord.js/src/index.js:2:11)
at Module._compile (module.js:409:26)
at Object.Module._extensions…js (module.js:416:10)

i have installed discord.js with this command : npm install discord.js.

My scritp is this:

var Discord = require (“discord.js”);
var bot= new Discord.client();

What’s is the problem?

Thanks in advance



Put "use strict"; with the quotes at the top of the file. This enables strict mode, which allows let, const, function, and class.


Thanks a lot but running the script i have got the error . As suggested i put ‘’ use strict’’;. Other suggestion?


I’m experiencing this error now, months later. Has someone finally found a work around?
“use strict”; does not work.