【发布时间】:2018-03-10 12:34:47
【问题描述】:
我正在尝试通过 Angular CLI 创建服务,但它抛出以下错误:
$ ng g service services/client
E:\MyApp\MyAngularJS proj\ng5\12Proj\clientpanel\node_modules\@angular\cli\models\config\config.js:89
throw new InvalidConfigError(common_tags_1.stripIndent
InvalidConfigError: Parsing 'E:\MyApp\MyAngularJS proj\ng5\12Proj\clientpanel\.angular-cli.json' failed. Ensure the file is valid JSON.
Error: Unexpected token ] in JSON at position 511
at Function.fromConfigPath (E:\MyApp\MyAngularJS proj\ng5\12Proj\clientpanel\node_modules\@angular\cli\models\config\config.js:89:19)
at Function.fromProject (E:\MyApp\MyAngularJS proj\ng5\12Proj\clientpanel\node_modules\@angular\cli\models\config.js:67:46)
at Object.<anonymous> (E:\MyApp\MyAngularJS proj\ng5\12Proj\clientpanel\node_modules\@angular\cli\commands\build.js:10:35)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
at Module.require (module.js:604:17)
at require (internal/module.js:11:18)
删除node_modules 并运行npm install 仍然收到上述错误。
卸载 Angular CLI 并再次全局安装。
【问题讨论】:
-
ng generate service [name]给表格。 -
它确实清楚地表明您的 .angular-cli.json 包含无效的 json。你检查了吗?可能会在这里发布
-
@AbhishekEkaanth 也尝试使用 ng generate 服务。还是没有运气
标签: angular angular-cli