@angular/cli not working after installation

Viewed 1979

I have installed the @angular/cli on my MacBook machine. Node server version is v6.9.5 and the npm version is 3.10.10. I have ran the following command to install the @angular/cli.

sudo npm install -g @angular-cli

When I run the ng help command or any command for ng. It shows me the following error

Parsing .angular-cli.json failed. Please make sure your .angular-cli.json is valid JSON. Error: SyntaxError: Unexpected token u in JSON at position 22

InvalidConfigError: Parsing .angular-cli.json failed. Please make sure your 
.angular-cli.json is valid JSON. 
Error: SyntaxError: Unexpected token u in JSON at position 22
   at InvalidConfigError (/usr/local/lib/node_modules/@angular/cli/models/config/config.js:10:9)
   at Function.fromConfigPath (/usr/local/lib/node_modules/@angular/cli/models/config/config.js:77:19)
   at Function.fromProject (/usr/local/lib/node_modules/@angular/cli/models/config.js:96:46)
   at Object.<anonymous> (/usr/local/lib/node_modules/@angular/cli/commands/build.js:7:35)
   at Module._compile (module.js:570:32)
   at Object.Module._extensions..js (module.js:579:10)
   at Module.load (module.js:487:32)
   at tryModuleLoad (module.js:446:12)
   at Function.Module._load (module.js:438:3)
   at Module.require (module.js:497:17)

I also uninstalled and @angualr/cli and clear the cache then reinstalled @angualr/cli. I run the following command.

sudo npm uninstall -g @angular-cli 
npm cache clean sudo 
npm install -g @angular-cli

Still the same issue is appearing.

5 Answers

i also face same issue, so i tried this method given below.

Clean uninstall of angular-cli, like npm uninstall -g angular-cli Clone this angular-cli repo, Go to the angular-cli repo folder, and run npm link, Go to my project folder Run npm link angular-cli Now to run ng command, I use ./node_modules/angular-cli/bin/ng from my project folder

You need to install @angular/cli globally to use it anywhere.To install it globally use cmd 'npm i -g @angular/cli',where -g means globally.Even update your angular version to latest.I think the error is because in older versions of angular,the angular.json file name used to be saved differently and its name is differently saved in newer or latest versions,so after installation it might not be able to read your angular.json file.

Related