Errors when trying to run ionic in ubuntu after updating to latest version


#1

Hi guys,

my first post here.

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)

Block-scoped declarations (let, const, function, class) not yet supported outside strict mode (CLI v1.7.14)

Your system information:

Cordova CLI: 5.4.1
Ionic Version: 1.2.4
Ionic CLI Version: 1.7.14
Ionic App Lib Version: 0.7.0
OS: Distributor ID: Ubuntu Description: Ubuntu 14.04.1 LTS
Node Version: v5.5.0


it used to work before but recently ubuntu asked me to update ionic(after which I also had to update nodejs)

The same happens when I run : ionic serve

Help would be appreciated on this

Thanks


#2

Not familiar with the error you got…

When I used Ubuntu I fixed most of my CLI problems by checking that the permissions are correct and trying with sudo if necessary.


#3

Are you using hawk library?


#4

I did not specifially download that,

I though it might have been downloaded as a dependency for ionic

will, try running the commands with sudo and let you know what happens


#5

sadly after fixing a few issues with the permissions,

I have come to the same error as above when using sudo


#6

no answers at all?

has no one here run into this problem?


#7

Hey I’m sorry you haven’t resolved you issue yet.

And sorry if this sound like a usual IT Tech Support answer but have you tried to uninstall and reinstall Ionic?

sudo npm uninstall -g ionic
sudo npm install -g ionic


#8

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

If you need to understand what the command does check out this answer on stackoverflow: http://stackoverflow.com/questions/9283472/command-to-remove-all-npm-modules-globally