angular-cli: Upgrading to angular 6 fails during angular-cli migration with unexpected token.
Versions
6.0.0-rc.5
Repro steps
ng update @angular/cli --migrate-only --from=1
using the following .angular-cli.json file.
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "ui-sdk"
},
"packageManager": "yarn",
"apps": [
{
"name": "lib",
"root": "src/lib",
"outDir": "lib",
"assets": [],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "sym",
"styles": [],
"scripts": [
"../../node_modules/@webcomponents/custom-elements/custom-elements.min.js"
],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
},
{
"name": "demo",
"root": "src/demo",
"outDir": "demo",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"test": "test.ts",
"polyfills": "polyfills.ts",
"tsconfig": "tsconfig.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "sym",
"styles": [
"vendor.scss",
"styles.scss"
],
"scripts": [
"../../node_modules/@webcomponents/custom-elements/custom-elements.min.js",
"../../vendor/vts.js"
],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts",
"e2e": "environments/environment.e2e.ts",
"upgrade": "environments/environment.upgrade.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/lib/tsconfig.json",
"exclude": "**/node_modules/**"
},
{
"project": "src/lib/tsconfig.spec.json",
"exclude": "**/node_modules/**"
},
{
"project": "src/demo/tsconfig.json",
"exclude": "**/node_modules/**"
},
{
"project": "src/demo/tsconfig.spec.json",
"exclude": "**/node_modules/**"
},
{
"project": "src/testing/tsconfig.json",
"exclude": "**/node_modules/**"
},
{
"project": "src/cli/tsconfig.json",
"exclude": "**/node_modules/**"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css"
}
}
Observed behavior
mkrotscheck-a02:sdk mkrotscheck$ ng update @angular/cli --migrate-only --from=1
Updating karma configuration
Updating configuration
Removing old config file (.angular-cli.json)
Writing config file (angular.json)
Unexpected token / in JSON at position 240
Desired behavior
Successful app migration, or helpful error 😃
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 3
- Comments: 35 (3 by maintainers)
Commits related to this issue
- fix(@schematics/angular): use the JSON AST for changing JSON files in migration Fix angular/angular-cli#10396 — committed to hansl/devkit by hansl 6 years ago
- fix(@schematics/angular): use the JSON AST for changing JSON files in migration Fix angular/angular-cli#10396 — committed to hansl/devkit by hansl 6 years ago
- fix(@schematics/angular): use the JSON AST for changing JSON files in migration Fix angular/angular-cli#10396 — committed to hansl/devkit by hansl 6 years ago
- fix(@schematics/angular): use the JSON AST for changing JSON files in migration Fix angular/angular-cli#10396 — committed to angular/devkit by hansl 6 years ago
- fix(@schematics/angular): use the JSON AST for changing JSON files in migration Fix angular/angular-cli#10396 — committed to angular/angular-cli by hansl 6 years ago
Hey, After alot of research, I have come up with following solution and got success in updating my local project to Angular 6.0.1:
Please respond and share! Thanks
update: this is still an issue with 6.0 final
I am getting a slightly different error (6.0 final)
I can’t see how there is a problem at 0:0. The first character in
.angular-cli.json
is an open bracket{
. Is there an encoding issue or something?I can confirm that the issue still exists in 6.0 final
Right, so I’ve done some digging around and found that it’s not actually the writing of the angular.json file that fails. The error comes from the following step in
updateSpecTsConfig(config)
:Writing the buffer to console reveals the following string:
Which fails on the line
"files": ["test.ts" "polyfills.ts"
However, when inspecting the actual file, it only has
"files": ["test.ts"]
None of the tsconfig.spec.json files have any reference to polyfills.ts, so it’s still a mystery how or why this suddenly shows up.Commenting out that part from the chain, and the rest of the processes run by smoothly:
node_modules/@schematics/angular/migrations/update-6/index.js
For
Invalid JSON character: "" at 0:0
please see the fix in #10715I had similar problem, updating Node from v6.10.2 to v10.1.0 did the trick.
I’m getting the same as Swellenator in 6.0 final. My “root” = “src”
Note: I had to delete a private npm package reference in order to get past a “not found” error but then I got this error. Probably unrelated but wanted to mention it in case.
@krotscheck and @gnomeontherun can you try with
@angular/cli@6.0.0-rc.7
? Using your.angular-cli.json
files and runningng update @angular/cli
, I did not see the errors.