Reputation: 885
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.
Upvotes: 3
Views: 2543
Reputation: 243
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.
Upvotes: 0
Reputation: 661
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
Upvotes: 0
Reputation: 4756
The package you mentioned is not valid. For fresh installation use npm install -g @angular/cli
.
Check here for more details https://github.com/angular/angular-cli#installation
Also If you are upgrading follow this https://github.com/angular/angular-cli#updating-angular-cli
If you upgrading from a beta/RC version follow this https://github.com/angular/angular-cli/wiki/stories-1.0-update
angular-cli
uses angular.cli.json.
whereas @angular/cli
uses .angular.cli.json
Upvotes: 0
Reputation: 68685
@angular-cli
is the previous version. Now you need to
npm install -g @angular/cli
to work with @angular/cli
version
Upvotes: 1
Reputation: 2290
The package is called @angular/cli
, so do npm install -g @angular/cli
.
Upvotes: 4