New to Ionic - Unexpected identifier

Hey all,

I downloaded node and Cordova, and was trying to install Ionic per (https://ionicframework.com/docs/guide/installation.html), but am receiving the following error:

$ sudo npm install -g cordova
$ sudo npm install -g cordova
^^^^
SyntaxError: Unexpected identifier

Rookie error, but could someone help?

Thanks!
Ben

something’s wrong with your app.js or controller.js file i think?

Are you entering this :

$ sudo npm install -g cordova

Or this :

sudo npm install -g cordova

You may need to get NPM and Node JS packages
https://www.npmjs.com/package/download
EDIT: Can see you already have node

Thank you both for your help! I was using, “$ sudo npm install -g ionic”. I am pretty junior in all things development, so how would I fix my app.js or controller.js?

You don’t need the $ sign for you statement. In terminal on Mac, Linux usually there is a $ at the end of the line. The dollar in the Ionic docs just what the command will look like on your terminal and a bit of a suggestion that the line you see should be used in terminal. In windows or other OS they usually end a line with ‘>’ or something like that.

So to fix, just ignore the dollar sign, the right command will be :

sudo npm install -g ionic

edit: https://ubuntuforums.org/showthread.php?t=1852263 for reasons as to why its a dollar

:slight_smile:

1 Like

Please don’t run node as root. Just say no to sudo. Use nvm.

1 Like