0

Hello I have researched this issue and have implemented two solutions that worked for others but I am still getting the same error. I am walking through this tutorial here:

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

However when running npm start in the Frontend directory I receive an error that reads

Parsing angular-cli.json failed. Please make your angular-cli.json is valid. SyntaxError: Unexpected token ? at position 0.

I have tried the solution here:

Parsing angular-cli.json failed

by building a new project with angular-cli, pasting the angular-cli.json file from new project while changing the name and OutDir. Then I went to tools -- options -- text editor -- general -- and unchecked "AutoDetect UTF 8 encoding without signature".

However I still get the same error. This is really frustrating.

angular-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": {}
  }
}
8
  • 1
    I've gotten this when VS encodes it using UTF-BOM-8. If you have Notepad++, try to open it in there, and in the encoding menu set it to just plain UTF-8 Commented Apr 20, 2017 at 18:24
  • @Steveadoo Ok im going to try it now. One moment...... Commented Apr 20, 2017 at 18:26
  • Unfortunately it did not work. Any other suggestions? Commented Apr 20, 2017 at 18:31
  • 1
    Could you upload your file somewhere? Instead of just pasting the contents? Commented Apr 20, 2017 at 18:32
  • 1
    Maybe you can just open the file in a hex editor (there are even online editors) and see what bytes are at the beginning. As Steveadoo pointed out, you could try to change your editor encoding so it doesn't write byte order mark (BOM) to the beginning of the file. Commented Apr 20, 2017 at 19:12

1 Answer 1

0

To solve this problem I had to restart the tutorial from the beginning. But before doing so I had to go to:

Tools | Options | Text Editor | General: then uncheck Auto-detect UTF-8 encoding without signature and Follow project coding conventions.

Then begin the tutorial and everything should work. No amount of deleting and re-adding the angular-cli.json file or changing the text editor settings or making sure the file was not using UTF-BOM would work. In my experience, if you receive this error you must start from the beginning after adjusting the settings

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.