davidbonnet / astring

🌳 Tiny and fast JavaScript code generator from an ESTree-compliant AST.

Home Page:https://david.bonnet.cc/astring/demo/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

bingosxs opened this issue · comments

Motivation

add "use strict";
to astring/bin/astring to eliminate error message from nodejs.

Expected behavior

should run normally

Actual behavior

astring/bin/astring:35
for (let i = 0, length = argv.length; i < length; i++) {
^^^

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:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3

@bingosxs Are you using node in version 4.x.x?
Edit: If so, then I'd suggest to upgrade node to version 6.

The version is v4.2.6.
This is the default from ubuntu 16.04.

@bingosxs Node v4 is not supported anymore since f8c5cb2. I can merge a PR with that change, but I highly recommend using nvm (Node Version Manager) to install Node versions specific for a project.