question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected token . error about .forRoot()

See original GitHub issue

I’m submitting a…


[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request

In package


[ ] @ng-toolkit/init
[ ] @ng-toolkit/serverless
[x] @ng-toolkit/universal

Current behavior

SyntaxError: Unexpected token . in JSON at position 1016
    at JSON.parse (<anonymous>)
    at Object.getDecoratorSettings (/home/gsong/poclcast/poclweb/node_modules/@ng-toolkit/_utils/index.js:378:21)
    at _utils_1.applyAndLog.schematics_1.chain (/home/gsong/poclcast/poclweb/node_modules/@ng-toolkit/universal/src/index.js:66:51)
    at MergeMapSubscriber.input.pipe.operators_1.mergeMap.inputTree [as project] (/home/gsong/poclcast/poclweb/node_modules/@angular-devkit/schematics/src/rules/call.js:77:24)
    at MergeMapSubscriber._tryNext (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/mergeMap.js:122:27)
    at MergeMapSubscriber._next (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/mergeMap.js:112:18)
    at MergeMapSubscriber.Subscriber.next (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Subscriber.js:103:18)
    at MergeMapSubscriber.notifyNext (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/mergeMap.js:141:26)
    at InnerSubscriber._next (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/InnerSubscriber.js:30:21)
    at InnerSubscriber.Subscriber.next (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Subscriber.js:103:18)
    at TapSubscriber._next (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/tap.js:109:26)
    at TapSubscriber.Subscriber.next (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Subscriber.js:103:18)
    at TapSubscriber._next (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/tap.js:109:26)
    at TapSubscriber.Subscriber.next (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Subscriber.js:103:18)
    at TakeLastSubscriber._complete (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/takeLast.js:109:29)
    at TakeLastSubscriber.Subscriber.complete (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Subscriber.js:128:18)
    at MapSubscriber.Subscriber._complete (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Subscriber.js:146:26)
    at MapSubscriber.Subscriber.complete (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Subscriber.js:128:18)
    at TapSubscriber._complete (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/tap.js:129:33)
    at TapSubscriber.Subscriber.complete (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Subscriber.js:128:18)
    at TapSubscriber._complete (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/tap.js:129:33)
    at TapSubscriber.Subscriber.complete (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Subscriber.js:128:18)
    at TakeLastSubscriber._complete (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/takeLast.js:112:21)
    at TakeLastSubscriber.Subscriber.complete (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Subscriber.js:128:18)
    at MergeMapSubscriber._complete (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/mergeMap.js:137:30)
    at MergeMapSubscriber.Subscriber.complete (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Subscriber.js:128:18)
    at Observable._subscribe (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/observable/scalar.js:7:20)
    at Observable.subscribe (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Observable.js:162:69)
    at MergeMapOperator.call (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/mergeMap.js:87:23)
    at Observable.subscribe (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Observable.js:159:22)
    at TakeLastOperator.call (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/takeLast.js:71:23)
    at Observable.subscribe (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Observable.js:159:22)
    at DoOperator.call (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/tap.js:71:23)
    at Observable.subscribe (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Observable.js:159:22)
    at DoOperator.call (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/tap.js:71:23)
    at Observable.subscribe (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Observable.js:159:22)
    at MapOperator.call (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/map.js:62:23)
    at Observable.subscribe (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Observable.js:159:22)
    at TakeLastOperator.call (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/takeLast.js:71:23)
    at Observable.subscribe (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Observable.js:159:22)
    at DoOperator.call (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/tap.js:71:23)
    at Observable.subscribe (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Observable.js:159:22)
    at DoOperator.call (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/tap.js:71:23)
    at Observable.subscribe (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Observable.js:159:22)
    at /home/gsong/poclcast/poclweb/node_modules/rxjs/internal/util/subscribeTo.js:22:31
    at Object.subscribeToResult (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/util/subscribeToResult.js:7:45)
    at MergeMapSubscriber._innerSub (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/mergeMap.js:132:38)
    at MergeMapSubscriber._tryNext (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/mergeMap.js:129:14)
    at MergeMapSubscriber._next (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/mergeMap.js:112:18)
    at MergeMapSubscriber.Subscriber.next (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Subscriber.js:103:18)
    at MergeMapSubscriber.notifyNext (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/mergeMap.js:141:26)
    at InnerSubscriber._next (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/InnerSubscriber.js:30:21)
    at InnerSubscriber.Subscriber.next (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Subscriber.js:103:18)
    at /home/gsong/poclcast/poclweb/node_modules/rxjs/internal/util/subscribeTo.js:17:28
    at Object.subscribeToResult (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/util/subscribeToResult.js:7:45)
    at MergeMapSubscriber._innerSub (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/mergeMap.js:132:38)
    at MergeMapSubscriber._tryNext (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/mergeMap.js:129:14)
    at MergeMapSubscriber._next (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/mergeMap.js:112:18)
    at MergeMapSubscriber.Subscriber.next (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Subscriber.js:103:18)
    at Observable._subscribe (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/observable/scalar.js:6:20)
    at Observable._trySubscribe (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Observable.js:177:25)
    at Observable.subscribe (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Observable.js:162:93)
    at MergeMapOperator.call (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/mergeMap.js:87:23)
    at Observable.subscribe (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Observable.js:159:22)
    at MergeMapOperator.call (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/mergeMap.js:87:23)
    at Observable.subscribe (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Observable.js:159:22)
    at MergeMapOperator.call (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/operators/mergeMap.js:87:23)
    at Observable.subscribe (/home/gsong/poclcast/poclweb/node_modules/rxjs/internal/Observable.js:159:22)
    at Domain.bugsnag.autoNotify (/home/gsong/poclcast/poclweb/node_modules/@ng-toolkit/_utils/index.js:412:33)
    at Domain.run (domain.js:242:14)
    at /home/gsong/poclcast/poclweb/node_modules/bugsnag/lib/bugsnag.js:298:20
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)

Expected behavior

No error

Minimal reproduction of the problem with instructions

  1. Add any module which calls forRoot() in app.module
  2. ng add @ng-toolkit/universal

What is the motivation / use case for changing the behavior?

Environment


Angular version: X.Y.Z


Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
realgsongcommented, May 30, 2018

I confirmed that this error has been fixed. Thx.

1reaction
maciejtredercommented, May 29, 2018

Now it should work. Checked with the following

@NgModule
:

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
        SomeModule.forRoot(),
        OtherModule.forChild({
                "something": "someValue",
                'anotherThing': 'anotherValue'
        })
  ],
  providers: [],
  bootstrap: [AppComponent]
})
Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular 4 recaptcha - unexpected token - Stack Overflow
forRoot(), RecaptchaFormsModule. And when I run the app, I get this error in Chrome: "index.debug.html:33 Error: Unexpected token <".
Read more >
Uncaught SyntaxError: Unexpected token import #1755 - GitHub
It is a great package I use since angular RCs. I was excited to give a try to last angular-compilers after #1599 was...
Read more >
missing file lib/angular2-modal/plugins/bootstrap.js
Error: SyntaxError: Unexpected token < at eval (<anonymous>) at Object.eval ... forRoot(), BootstrapModalModule, LOGIN_ROUTER_PROVIDERS ], declarations: ...
Read more >
Unit-Test errors: SyntaxError: Unexpected token export
p>I upgraded my project from the PRO version downloaded as *zip folder to an installation with npm and my received gitlab account.
Read more >
'Unexpected token <' on every new build of angular production ...
'Unexpected token <' on every new build of angular production PWA until ... build the first time I visit the site I get...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found