angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Parsing .angular-cli.json failed.

Open MaxGoh opened this issue 9 years ago • 5 comments

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

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

I'm getting this issue no matter what I do now, from ng -v to ng new to anything ng related. What I did was merely changed to global manager to yarn and everything starts to break. I tried reinstalling @angular/cli, removing node_modules from library and nothing works. I can't find this .angular-cli.json file.

Versions.

$ node -v v7.7.4 $ npm -v 4.1.2

Repro steps.

The log given by the failure.

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 Function.fromConfigPath (/usr/local/lib/node_modules/@angular/cli/models/config/config.js:74:19) at Function.fromProject (/usr/local/lib/node_modules/@angular/cli/models/config.js:91:46) at Object. (/usr/local/lib/node_modules/@angular/cli/commands/build.js:7:35) at Module._compile (module.js:571:32) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3) at Module.require (module.js:498:17) at require (internal/module.js:20:19)

Desired functionality.

Mention any other details that might be useful.

MaxGoh avatar Mar 26 '17 18:03 MaxGoh

The error looks like it's to do with malformed JSON. I'm guessing you have a trailing comma somewhere or unquoted string :)

Could you share your .angular-json?

intellix avatar Mar 26 '17 20:03 intellix

@MaxGoh You said you can't find the file. If you are on an *unix platform it'd be hidden. Just a reminder :)

edemirkan avatar Mar 26 '17 21:03 edemirkan

Look at character 22, there should be a u there that is out of a string. Sometimes people think that undefined is valid JSON but it's not.

Hope this helps. I'm going to close this as resolved.

hansl avatar Mar 26 '17 22:03 hansl

This started happening on my system after trying to set the package manager to yarn. ng new stopped working. I then realized that there was a .angular-cli.json file added in my home directory, containing the following:

{
  "packageManager": undefined
}

Which isn't valid JSON. Deleting this file fixes everything. Same issue seems to be occurring in #6087

victormejia avatar Apr 28 '17 07:04 victormejia

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.