question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Loading module 'telegram'... SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

See original GitHub issue

@GochoMugo Being blissfully ES6 ignorant, I’m stuck trying to update the Telegram module for Concierge (previously known as Kassy) with the following error:

Loading module 'telegram'...
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:387:25)
  at Module._extensions..js (module.js:422:10)
  at Object.require.extensions.(anonymous function) [as .js] (/Users/phillipadsmith/Development/concierge-plus-br/node_modules/babel-register/lib/node.js:152:7)
  at Module.load (/Users/phillipadsmith/Development/concierge-plus-br/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
  at Function.Module._load (module.js:314:12)
  at Module.require (module.js:367:17)
  at require (internal/module.js:16:19)
  at Object.<anonymous> (/Users/phillipadsmith/Development/concierge-plus-br/node_modules/tgfancy/lib/index.js:10:16)
  at Module._compile (module.js:413:34)
  at Module._extensions..js (module.js:422:10)
  at Object.require.extensions.(anonymous function) [as .js] (/Users/phillipadsmith/Development/concierge-plus-br/node_modules/babel-register/lib/node.js:152:7)
  at Module.load (/Users/phillipadsmith/Development/concierge-plus-br/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
  at Function.Module._load (module.js:314:12)
  at Module.require (module.js:367:17)
  at require (internal/module.js:16:19)
  at fs.readdirSync.forEach.installAndRequire (/Users/phillipadsmith/Development/concierge-plus-br/core/unsafe/require.js:96:15)
  at func (/Users/phillipadsmith/Development/concierge-plus-br/core/unsafe/require.js:124:21)
  at Object.<anonymous> (/Users/phillipadsmith/Development/concierge-plus-br/modules/kpm_telegram/telegram.js:3:15)
  at Module._compile (module.js:413:34)
  at loader (/Users/phillipadsmith/Development/concierge-plus-br/node_modules/babel-register/lib/node.js:144:5)
  at Object.require.extensions.(anonymous function) [as .js] (/Users/phillipadsmith/Development/concierge-plus-br/node_modules/babel-register/lib/node.js:154:7)
  at Module.load (/Users/phillipadsmith/Development/concierge-plus-br/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
  at Function.Module._load (module.js:314:12)
  at Module.require (module.js:367:17)
  at require (internal/module.js:16:19)
  at fs.readdirSync.forEach.installAndRequire (/Users/phillipadsmith/Development/concierge-plus-br/core/unsafe/require.js:96:15)
  at func (/Users/phillipadsmith/Development/concierge-plus-br/core/unsafe/require.js:124:21)
  at /Users/phillipadsmith/Development/concierge-plus-br/core/modules/kassy/kassyModule.js:66:17
  at Object.exports.loadModule (/Users/phillipadsmith/Development/concierge-plus-br/core/modules/kassy/kassyModule.js:94:35)
  at ModuleLoader._loadModuleInternal (/Users/phillipadsmith/Development/concierge-plus-br/core/modules/modules.js:31:59)
  at ModuleLoader.loadModule (/Users/phillipadsmith/Development/concierge-plus-br/core/modules/modules.js:118:27)
  at ModuleLoader.loadAllModules (/Users/phillipadsmith/Development/concierge-plus-br/core/modules/modules.js:156:30)
  at Platform.start (/Users/phillipadsmith/Development/concierge-plus-br/core/platform.js:181:32)
  at Object.exports.run (/Users/phillipadsmith/Development/concierge-plus-br/core/startup/startup.js:48:18)
  at Object.<anonymous> (/Users/phillipadsmith/Development/concierge-plus-br/main.js:45:9)
  at Module._compile (module.js:413:34)
  at Object.Module._extensions..js (module.js:422:10)
  at Module.load (module.js:357:32)
  at Function.Module._load (module.js:314:12)
  at Function.Module.runMain (module.js:447:10)
  at startup (node.js:142:18)
  at node.js:939:3

This is a vanilla/default install of Concierge with the existing Telgram integration loaded, and where I’ve substituted tgfancy for node-telegram-bot-api When I try to start the integration, it fails per the above message.

Any help around my ignorance here greatly appreciated. 😃

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
drknocommented, Dec 8, 2016

If you don’t start with the --debug argument it suppresses stack traces (and cause the core loader failed to load your module, rather than your module actually loading then failing it assumes that the core platform was at fault, hence !CORE!) as many stack-traces from Concierge aren’t actually problems with Concierge itself. Not entirely certain why you are getting your exception however, cause if babel is loading correctly it should be editing your code to have a "use strict"; at the top. Concierge babel does not touch npm modules, and your version of node is old enough that it won’t allow ES6 const and let without "use strict"; defined in each file (babel does this for all other files in Concierge). If both https://github.com/GochoMugo/tgfancy/blob/master/lib/client.js and https://github.com/GochoMugo/tgfancy/blob/master/lib/index.js have this defined at the top of them, it will solve this problem in older versions of node.

0reactions
kamikazechasercommented, Dec 10, 2016

@phillipadsmith I suggest you manually add the 'use strict' in the tgfancy files in node_modules/ folder. You should still be able to use tgfancy with the older versions, I believe so! 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Block scoped declarations (let, const, function,class) not yet ... - GitHub
I was trying to run the bot after writing some lines of code. I expected that after running node index.js , there will...
Read more >
Block-scoped declarations (let, const, function, class) not yet ...
js to a newer (or latest) version that supports es6 syntax. The error message said 'not yet supported outside strict mode'. Share.
Read more >
Block-scoped declarations (let, const, function, class) not yet ...
SyntaxError : Block-scoped declarations (let, const, function, class) not yet supported outside strict mode. How to resolve this issue “ ...
Read more >
nodejs/node - Gitter
SyntaxError : Block-scoped declarations (let, const, function, class) not yet supported outside strict mode at exports.runInThisContext (vm.js:53:16)
Read more >
Uncaught SyntaxError: Block-scoped declarations (let, const ...
Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found