When trying to run ionic in ubuntu using the folling command: ionic run android
I am getting the below error:
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 Object.Module._extensions…js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object. (/usr/local/lib/node_modules/hawk/lib/index.js:5:33)
at Module._compile (module.js:413:34)
at Object.Module._extensions…js (module.js:422:10)
The error you are getting usually occurs when you are trying to execute a function that doesn’t have “use strict” at the top of it’s document. That tag is necessary if you are using let, const, function or class … My guess is that that vm.js file needs to have that “use strict” line at the top… Also I’m guessing that file is not one of your project’s files, instead it’s one of the node_modules you have installed.
My recommendation is to uninstall all the node modules you have installed globally and reinstall ionic + cordova … This will basically remove all the node modules you have and it will install a fresh updated copy for you of the modules you need only.
To uninstall all node modules on Ubuntu run the following command: npm -g ls | grep -v 'npm@' | awk '/@/ {print $2}' | awk -F@ '{print $1}' | xargs npm -g rm