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

@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. 😃

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 16 (1 by maintainers)

Most upvoted comments

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.