angular-cli: Error showed up while run the command `ng generate module about`
Versions
λ ng --version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 6.0.1
Node: 9.8.0
OS: win32 x64
Angular: 6.0.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.6.1
@angular-devkit/build-angular 0.6.1
@angular-devkit/build-optimizer 0.6.1
@angular-devkit/core 0.6.1
@angular-devkit/schematics 0.6.1
@angular/cli 6.0.1
@ngtools/webpack 6.0.1
@schematics/angular 0.6.1
@schematics/update 0.6.1
rxjs 6.1.0
typescript 2.7.2
webpack 4.6.0
Repro steps
- ng new nebular-demo
- cd nebular-demo
- ng serve
- ng generate module about
Observed behavior
λ ng generate module about
Unexpected token ] in JSON at position 720
Same error when run command ng generate component about
What is happening?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15
Commits related to this issue
- fix(@schematics/angular): Fix JSON parsing fixes #10880 — committed to Brocco/angular-cli by Brocco 6 years ago
- fix(@schematics/angular): Fix JSON parsing fixes #10880 — committed to Brocco/angular-cli by Brocco 6 years ago
- fix(@schematics/angular): Fix JSON parsing fixes #10880 — committed to Brocco/angular-cli by Brocco 6 years ago
- fix(@schematics/angular): Fix JSON parsing fixes #10880 — committed to Brocco/angular-cli by Brocco 6 years ago
- fix(@schematics/angular): Fix JSON parsing fixes #10880 — committed to Brocco/angular-cli by Brocco 6 years ago
- fix(@schematics/angular): Fix JSON parsing fixes #10880 — committed to filipesilva/angular-cli by Brocco 6 years ago
- fix(@schematics/angular): Fix JSON parsing fixes #10880 — committed to filipesilva/angular-cli by Brocco 6 years ago
I have found the problem. check the angular.json file.
just remove the comma after “src/assets” and “…default.css” like below:
then will fix the problem. Somehow if the comma is in js code it will work. But not here.
Thanks to @xlxAciDxlx !
Perhaps an issue with the encoding of angular.json, it’s just a guess based on other related issues. Try converting your angular.json file to utf-8 without BOM and see if that helps. And of course verify that angular.json contains only valid json 😃
@hitokiri May be you need to check the other positons that not same as my. Or just use the JSONLint tool mentioned by @xlxAciDxlx
I’ll try it to see if it works for me.
Alright, my issue’s fixed. It appears the error’s caused by something being wrong in
angular.json
- I must’ve missed it when manually looking through my files. I threw it in JSONLint and it immediately threw an error. You can obviously do this for other files, but I’m going to assume this error is mainly caused byangular.json
.When I searched for the issue (to see if it already existed), yours was the first of many that had come up.
Yeah, same issue here. Running a linter and
tsc
all work fine, it just seems to be generating things that’s broken for me.