root@localhost:$ ng
/usr/local/lib/node_modules/angular-cli/node_modules/@ngtools/json-schema/src/schema-class-factory.js:33
result.push(...indices);
^^^
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.
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
How to resolve it! Please me! on Ubuntu 16.04 LTS
Just installed the CLI myself this morning from an 'npm install -g angular-cli' and i get exactly the same issue when running 'ng new'.
I'm on MacOS though.
You should be using npm install -g @angular/cli
Same problem after running the above command. 'ng new' just gives the following:
iains-iMac:git iain$ ng new iainsangular
/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:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
This seems to be occurring too on Win10, with the following:
Node v4.4.7
NPM v4.2.0
Strangely, ng --v causes the same error to pop up.
And this is why you should use the issue template... Especially the 'Versions' section.
Angular CLI uses new Javascript features that aren't available in Node 4, try upgrading Node to 6.9.0 or above.
Thanks Ionaru. Upgraded to v6.9.0 and error immediately disappeared.
CLI Quickstart at angular.io still mentions _at least node 4.x.x_ in Step 1.
@thojo Actually the information has been changed on Github, but the website hasn't updated yet.
I fixed it with updated version of nodejs npm install npm@latest -g
Yeah I'm sorry about that, it took us a while to update the CLI quickstart. The problem really was node and npm version.
Had the same issue; I updated npm but that didnt solve the issue.
So I uninstalled node.js from my computer and installed again, which fixed the problem.
Same problem with ubuntu, even if you use the newest package via repo install it has still the version 4.X
Check your node version node --version
Or better use node version manager (nvm)
Try this guys...
npm cache clean -f
npm install -g n
n stable
@TheNuclearCat @sghaleb1
Ubuntu (and some other Linux distributions) will not upgrade NodeJS to new major versions, you have to redo the installation steps to upgrade NodeJS.
For example the commands below will install NodeJS 6
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
And these commands below will install NodeJS 8
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
Notice the curl link changed from 6 to 8.
Minor version updates, for example 8.0.0 to 8.1.0, will then get installed with normal system updates.
lonaru, you comment helped me a lot. Thanks very much!
I have same issue on Ubuntu 16.04, @Ionaru comment solve my issue, thanks,
@Ionaru's comment solved this for me on ubuntu 17.04. Reason for angular-cli not working was that legacy node was installed. Thank you ionaru!
how to update the node ..??? i have tried all the ways to update or upgrade still my node version is
v4.2.6?? wt should i do?
You're probably running into the issue with node
and nodejs
pointing to different installs. If you tried the following below, then the new version is node
and you can remove nodejs
.
npm cache clean -f
npm install -g n
n stable
Side note, I had to run npm install @angular/cli
to my local working directory and then to my global too at sudo npm install -g @angular/cli
.
If you follow the apt install I would suggest to remove any locally installed node first:
sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}
Thank you Ionaru you the new repo and update worked well for me.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
And this is why you should use the issue template... Especially the 'Versions' section.
Angular CLI uses new Javascript features that aren't available in Node 4, try upgrading Node to 6.9.0 or above.
https://github.com/angular/angular-cli#prerequisites