Skip to content

Upgrading to angular 6 fails during angular-cli migration with unexpected token. #10396

Closed

Description

@krotscheck

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 :)

Activity

  1. krotscheck commented on Apr 19, 2018

    @krotscheck
    Author
  2. krotscheck commented on Apr 19, 2018

    @krotscheck
    Author

    A bit of comment-out-line-by-line debugging: The issue appears to be the

    "root": "path-with-directory/slash"

    if I remove the subdirectory, it works like a charm.

  3. gnomeontherun commented on Apr 25, 2018

    @gnomeontherun

    I'm also having the same issue for Clarity, which you can find our project at https://github.com/vmware/clarity/tree/website/latest. The angular-cli.json file is at https://github.com/vmware/clarity/blob/website/latest/.angular-cli.json.

    ➜ npm install @angular/cli@next
    ...
    added 31 packages, removed 564 packages and updated 39 packages in 12.81s
    ➜  ng update @angular/cli --from=1 --migrate-only
    The Angular CLI configuration format has been changed, and your existing configuration can
    be updated automatically by running the following command:
    
      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 838
    

    I haven't been able to migrate even with the suggestion by @krotscheck.

  4. added
    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
    on Apr 28, 2018
  5. added this to the v6.0.0 milestone on Apr 28, 2018
  6. StephenFluin commented on Apr 28, 2018

    @StephenFluin
    Contributor

    @hansl I think we already fixed this one, can you check?

  7. filipesilva commented on Apr 30, 2018

    @filipesilva
    Contributor

    @krotscheck and @gnomeontherun can you try with @angular/cli@6.0.0-rc.7? Using your .angular-cli.json files and running ng update @angular/cli, I did not see the errors.

  8. self-assigned this
    on Apr 30, 2018
  9. wopss commented on Apr 30, 2018

    @wopss

    @filipesilva I have the same problem with @angular/cli@6.0.0-rc.7 when upgrading from 1.7.4. My .angular-cli.json is

    {
        "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
        "project": {
            "name": "client"
        },
        "packageManager": "yarn",
        "apps": [
            {
                "root": "src/browser",
                "outDir": "../../Build/Client/ui",
                "assets": [],
                "index": "index.html",
                "main": "main.ts",
                "polyfills": "polyfills.ts",
                "tsconfig": "tsconfig.app.json",
                "prefix": "app",
                "styles": [
                    "styles/app.scss"
                ],
                "scripts": [],
                "environmentSource": "environments/environment.ts",
                "environments": {
                    "dev": "environments/environment.ts",
                    "prod": "environments/environment.prod.ts"
                }
            }
        ],
        "lint": [
            {
                "project": "src/browser/tsconfig.app.json",
                "exclude": "**/node_modules/**"
            }
        ],
        "defaults": {
            "styleExt": "scss",
            "class": {
                "spec": false
            },
            "component": {
                "spec": false
            },
            "directive": {
                "spec": false
            },
            "guard": {
                "spec": false
            },
            "module": {
                "spec": false
            },
            "pipe": {
                "spec": false
            },
            "service": {
                "spec": false
            }
        }
    }

    The output

    > 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 224
    

    Versions

    
         _                      _                 ____ _     ___
        / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
       / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
      / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
     /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                    |___/
    
    
    Angular CLI: 6.0.0-rc.7
    Node: 10.0.0
    OS: win32 x64
    Angular: 6.0.0-rc.6
    ... animations, common, compiler, compiler-cli, core, forms
    ... http, language-service, platform-browser
    ... platform-browser-dynamic, router
    
    Package                           Version
    -----------------------------------------------------------
    @angular-devkit/architect         0.5.10
    @angular-devkit/build-angular     0.5.10
    @angular-devkit/build-optimizer   0.5.10
    @angular-devkit/core              0.5.10
    @angular-devkit/schematics        0.5.10
    @angular/cli                      6.0.0-rc.7
    @ngtools/json-schema              1.1.0
    @ngtools/webpack                  6.0.0-rc.8
    @schematics/angular               0.5.10
    @schematics/update                0.5.10
    rxjs                              6.0.0
    typescript                        2.7.2
    webpack                           4.6.0
    
  10. assigned and unassigned on Apr 30, 2018
  11. added a commit that references this issue on Apr 30, 2018
    367786e
  12. krotscheck commented on Apr 30, 2018

    @krotscheck
    Author

    @filipesilva No luck from me, though likely for unrelated reasons. We just refactored into a yarn workspaces based monorepo, and attempting to migrate our project from within the child workspaces gave me this:

    mkrotscheck-a02:ui-sdk mkrotscheck$ ng update @angular/cli --migrate-only --from=1
    Could not find a package.json. Are you in a Node project?
    

    I suspect that issue's reported elsewhere.

    (Side note - yeah, I know ng now supports its own monorepo-style structure, and I'm trying to use it for a different project. In this one, unfortunately, we're shipping more-than-just angular packages, so I a more traditional monorepo is called for)

  13. added 2 commits that reference this issue on Apr 30, 2018
    169a426
    0ca869b
  14. 17 remaining items

  15. Ks89 commented on May 15, 2018

    @Ks89

    I confirm the solution of @phl3x0r.
    It's crazy, I know, but removing all lines in tsconfig files with test.ts and so on, I fixed this error.

    PS: I'm using angular-cli 6.0.1

  16. andynrkri commented on May 16, 2018

    @andynrkri

    In my case, I had commented a script array entry with /*..*/ in angular.json. Removing this resolved the error. I believe it happened because JSON doesn't support any comments as per specification.

  17. affilnost commented on May 16, 2018

    @affilnost

    I had similar problem, updating Node from v6.10.2 to v10.1.0 did the trick.

  18. bandersen22000 commented on May 28, 2018

    @bandersen22000

    I fixed the issue by converting the following .json files (tsconfig, angular-cli.json, tslint) to UTF8, without BOM.

  19. JigneshPatel04 commented on May 29, 2018

    @JigneshPatel04

    I have followed https://update.angular.io/ and
    When I run ng update @angular/cli

    Updating karma configuration
    Updating configuration
    Removing old config file (.angular-cli.json)
    Writing config file (angular.json)
    Invalid JSON character: "" at 0:0.

    Anyone know?

  20. Al-Sharif commented on Jun 4, 2018

    @Al-Sharif

    I was using visual studio code, i noticed the file encoding for angular-cli.json and package.json is UTF-8 and BOM, press on the label in the bottom then save with encoding and choose UTF-8. That's worked for me.

  21. JigneshPatel04 commented on Jun 4, 2018

    @JigneshPatel04

    My project tsconfig.json and tslint.json with UTF-8 and BOM so I choose UTF-8 and resolve it ago.
    but thanks to reply .

  22. added a commit that references this issue on Jun 6, 2018
    df09951
  23. dmsysop commented on Jun 13, 2018

    @dmsysop

    Guys, I was having the same problem and managed to fix just leaving the tslint.json file as it was by default.

    To avoid tslint "errors" I had commented on some of the lines that he understands as error, but that are not ... (whitespace true - for example)

    Just correcting this, he did the update normally!

    Hope this helps someone else.

    Good luck !!

  24. neridonk commented on Jun 21, 2018

    @neridonk

    You not only have to change tslint.json, you have to change also in folder "src" the tsconfigs , test.ts, . Any that is affected on this update

  25. bhaidar commented on Aug 10, 2018

    @bhaidar

    I am also facing a similar issue. I've detailed it here, if someone can have a look please.
    #11825

  26. RicardoGomesRocha commented on Sep 25, 2018

    @RicardoGomesRocha

    I my case I was getting the following error:

    Unexpected token T in JSON at position 0 TF400813: Resource not available for anonymous access. Client authentication required.

    The solution in my case could be found on this stackoverflow post

  27. xtrrdnryprgrmmr commented on Oct 15, 2018

    @xtrrdnryprgrmmr

    trying create a jhipster project with angular 6 .when i run "ng serve" command ,i took error in below.
    please help me
    Could not determine a single project for the 'serve' target.
    Error: Could not determine a single project for the 'serve' target.
    at ServeCommand.getProjectNamesByTarget (C:\Users\pc\complexdemo\node_modules@angular\cli\models\architect-command.js:184:19)
    at MergeMapSubscriber._loadWorkspaceAndArchitect.pipe.operators_1.concatMap [as project] (C:\Users\pc\complexdemo\node_modules@angular\cli\models\architect-command.js:58:43)
    at MergeMapSubscriber._tryNext (C:\Users\pc\complexdemo\node_modules\rxjs\internal\operators\mergeMap.js:122:27)
    at MergeMapSubscriber._next (C:\Users\pc\complexdemo\node_modules\rxjs\internal\operators\mergeMap.js:112:18)
    at MergeMapSubscriber.Subscriber.next (C:\Users\pc\complexdemo\node_modules\rxjs\internal\Subscriber.js:103:18)
    at TapSubscriber._next (C:\Users\pc\complexdemo\node_modules\rxjs\internal\operators\tap.js:109:26)
    at TapSubscriber.Subscriber.next (C:\Users\pc\complexdemo\node_modules\rxjs\internal\Subscriber.js:103:18)
    at MergeMapSubscriber.notifyNext (C:\Users\pc\complexdemo\node_modules\rxjs\internal\operators\mergeMap.js:141:26)
    at InnerSubscriber._next (C:\Users\pc\complexdemo\node_modules\rxjs\internal\InnerSubscriber.js:30:21)
    at InnerSubscriber.Subscriber.next (C:\Users\pc\complexdemo\node_modules\rxjs\internal\Subscriber.js:103:18)

  28. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    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.

  29. locked and limited conversation to collaborators on Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions