1

I am trying to install the Angular CLI on Ubnutu 17.04 with via

sudo npm install -g @angular/cli

However it generates the following warnings:

    npm WARN gentlyRm not removing /usr/local/bin/ng as it wasn't installed by /usr/local/lib/node_modules/@angular/cli
/usr/local/bin/ng -> /usr/local/lib/node_modules/@angular/cli/bin/ng
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modules/@angular/cli/node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

and once completed, although the ng executable is in my path, if I try to run any command (e.g. npm serve) I am given the following:

    /usr/local/lib/node_modules/@angular/cli/models/config/config.js:17
    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.<anonymous> (/usr/local/lib/node_modules/@angular/cli/models/config.js:3:18)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)

It appears to have (attempted?) to install Angular CLI 1.3.2 but the command ng --version doesn't even run. (Produces the error above). As a result I cannot run npm start for Angular 2 apps that I am building.

My npm version is 5.3.0, nodejs version is v4.7.2. I have tried many times now to get this to work and I'm starting to think that maybe there's a bug in npm or angular CLI because I've been successful at installing the Angular CLI on both Mac, Windows and ArchLinux on the command line. How can I get npm to run angular apps on Ubuntu?

2 Answers2

1

try using

sudo su

check the version of node and npm

Verify that you are running at least node 6.9.x and npm 3.x.x by running node -v and npm -v in a terminal/console window. Older versions produce errors, but newer versions are fine.

then use

npm install -g @angular/cli

create new folder

ng new my-dream-app

change the current directory to the newly created folder

cd my-dream-app

start the angular server with

ng serve

I recommend you to use 16.04 lts ubuntu verion

0

That version (1.3.x) for Angular CLI needs Node 6.9 or higher (read from @angular/cli from npm page here.

I suggest you to install node version manager (NVM) in order to manage different node versions, docs here

After getting the proper node version installed, try again to install angular cli and it should work fine.