2017-04-20 60 views
0

你好,我已经研究过这个问题,并已经实施了两个解决方案,为其他人工作,但我仍然得到相同的错误。我正通过本教程在这里:解析angular-cli.json失败。在位置0的语法错误

https://devblog.dymel.pl/2016/10/25/angular2-cli-with-aspnet-core-application-tutorial/

但是在前端目录中运行NPM开始,当我收到读

解析角cli.json失败的错误。请让你的angular-cli.json有效。 SyntaxError:意外的令牌?通过建设有角CLI一个新的项目,粘贴来自新项目的角cli.json文件,而更改名称

Parsing angular-cli.json failed

:在位置0

我已经试过这里的解决方案和OutDir。然后我去了工具 - 选项 - 文本编辑器 - 一般 - 并且未选中“AutoDetect UTF 8 encoding without signature”。

但是我仍然得到相同的错误。这真令人沮丧。

角cli.json

{ 
    "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 
    "project": { 
    "name": "MYPROJ" 
    }, 
    "apps": [ 
    { 
     "root": "src", 
     "outDir": "../Backend/wwwroot", 
     "assets": [ 
     "assets", 
     "favicon.ico" 
     ], 
     "index": "index.html", 
     "main": "main.ts", 
     "polyfills": "polyfills.ts", 
     "test": "test.ts", 
     "tsconfig": "tsconfig.app.json", 
     "testTsconfig": "tsconfig.spec.json", 
     "prefix": "app", 
     "styles": [ 
     "styles.css" 
     ], 
     "scripts": [], 
     "environmentSource": "environments/environment.ts", 
     "environments": { 
     "dev": "environments/environment.ts", 
     "prod": "environments/environment.prod.ts" 
     } 
    } 
    ], 
    "e2e": { 
    "protractor": { 
     "config": "./protractor.conf.js" 
    } 
    }, 
    "lint": [ 
    { 
     "project": "src/tsconfig.app.json" 
    }, 
    { 
     "project": "src/tsconfig.spec.json" 
    }, 
    { 
     "project": "e2e/tsconfig.e2e.json" 
    } 
    ], 
    "test": { 
    "karma": { 
     "config": "./karma.conf.js" 
    } 
    }, 
    "defaults": { 
    "styleExt": "css", 
    "component": {} 
    } 
} 
+1

我已经得到这个当VS它使用UTF-BOM-8编码的设置后启动。如果你有记事本+ + +,尝试在那里打开它,并在编码菜单中设置它只是普通的UTF-8 – Steveadoo

+0

@Steveadoo好吧即时将现在尝试它。一会儿...... – RyeGuy

+0

不幸的是它没有工作。还有其他建议吗? – RyeGuy

回答

0

为了解决这个问题,我不得不重新启动从一开始的教程。但是之前这样做我必须去:

工具|选项|文本编辑器|常规:然后取消选中自动检测无签名的UTF-8编码遵循项目编码约定。

然后开始教程,一切都应该工作。不删除和重新添加angular-cli.json文件或更改文本编辑器设置或确保文件未使用UTF-BOM都可以。根据我的经验,如果你收到此错误,你必须开始调整