Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting error after Angular cli update

Tags:

My angular-cli version was beta.16

I try to update by following command

npm uninstall -g angular-cli @angular/cli npm cache clean npm install -g @angular/cli@latest 

after succesfully install when i try to run any ng command

ng version  ng help 

I am getting this error

ng help /usr/local/lib/node_modules/@angular/cli/models/config/config.js:15     constructor(_configPath, schema, configJson, fallbacks = []) {                                                            ^  SyntaxError: Unexpected token =     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 Module.require (module.js:354:17)     at require (internal/module.js:12:17)     at Object.<anonymous> (/usr/local/lib/node_modules/@angular/cli/models/config.js:2:18)     at Module._compile (module.js:410:26)     at Object.Module._extensions..js (module.js:417:10) 
like image 454
Ashutosh Jha Avatar asked Feb 10 '17 13:02

Ashutosh Jha


2 Answers

You need Node version 6.x or higher

take a look here: https://github.com/angular/angular-cli/issues/4604

like image 105
Ahmed Musallam Avatar answered Oct 06 '22 01:10

Ahmed Musallam


As mentioned, you need Node version 6.x or higher.

Quick solution posted on Github by cdvillagra:

npm cache clean -f npm install -g n n stable 

(you might need to prefix those commands with sudo).

Also, on Ubuntu or similar you may want to remove your old version of node and then link the new one:

sudo ln -s /usr/local/bin/node /usr/bin/node

like image 32
Francesco Borzi Avatar answered Oct 06 '22 02:10

Francesco Borzi