Problem with ng serve when angular-cli.json is modified
OS?
Windows 10
Versions.
Ng Version: 1.0.0-beta.30
Node version: v7.5.0
Repro steps.
I changed the angular-cli.json file to add the jquery scripts
The log given by the failure.
Error that gets returned: Parsing angular-cli.json failed. Please make sure your angular-cli.json is valid JSON. Error: SyntaxError: Unexpected token in JSON at position 0
Mention any other details that might be useful.
When I try to add a third party global script (Jquery) is send back an invalid json error. It all did this when I modified the tsconfig file to add typings for hammerjs.
Here is the angular-cli.json file:
{
"project": {
"version": "1.0.0-beta.30",
"name": "m25-app"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"prefix": "app",
"styles": [
"styles.sass"
],
"scripts": [
"../node_modules/jquery/dist/jquery.min.js"
],
"environments": {
"source": "environments/environment.ts",
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"files": "src/**/*.ts",
"project": "src/tsconfig.json"
},
{
"files": "e2e/**/*.ts",
"project": "e2e/tsconfig.json"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "sass",
"prefixInterfaces": false,
"inline": {
"style": false,
"template": false
},
"spec": {
"class": false,
"component": true,
"directive": true,
"module": false,
"pipe": true,
"service": true
}
}
}
It might be your editor that adds weird characters to the file at save. Perhaps a byte order mark or similar. Please use UTF-8 without BOM if your editor is set to UTF-8 with BOM.
I was using Visual Studio Community 2017 so I scrapped that and started a new project using VSCode to modify the code. Now everything works just fine!
Hello I too have this problem and in my situation, his start with enter proposition command from generate new projest from cli 31 ng set --global packageManager=yarn'.
Visual Studio 2017: Tools | Options | Text Editor | General: uncheck Auto-detect UTF-8 encoding without signature and Follow project coding conventions. If you file was modified, copy a new one from another untouched project.
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.