-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected token ' in JSON at position 0 - After running ng-build/serve a few times #1960
Comments
Same issue. I can generate a new project, but the minute I try to move my app sources in and ng init things, all hell breaks loose. Windows 10 x64, TypeScript 2.0.0, webpack.8 release, Node v6.5.
|
I have noticed that I move back to the original Still nothing. Found from here that webpack doesnt support the lazy loading, so perhaps its related to that? |
Looks like it is to do with the lazy loading.
|
@ilikeprograms you're right! I was able to pinpoint this to my use of |
you can fix lazy loading by wrapping those with backticks instead: {
path: `callcentre`,
loadChildren: `app/callcentre/callcentre.module#CallCentreModule`
} |
Hmmmmm. Very nice idea. How does that work ? M: +44 (0)7428 759630
|
Haha backticks to the rescue! Nice fix! |
Very nice catch with the backticks indeed. Thx! I am also interested in the explanation. |
Single quotes are not valid JSON? |
@mjolk nope. Double quotes only for JSON |
@mjolk although it is important to point out that JSON and JavaScript objects at not exactly the same thing. |
on second thought it's indeed weird the backticks do work, must be some transform done somewhere. or something ;) |
and properly understand and return the modules in this case. Also refactored that function to be clearer, and added a test to cover. I made sure the test was failing before this PR ;) Fixes angular#1891, angular#1960. cc @filipesilva @ericjim @chalin - See similar angular#1972
and properly understand and return the modules in this case. Also refactored that function to be clearer, and added a test to cover. I made sure the test was failing before this PR ;) Fixes angular#1891, angular#1960. cc @filipesilva @ericjim @chalin - See similar angular#1972
) * fix(find-lazy-modules): Allow for any valid keys/value to be used and properly understand and return the modules in this case. Also refactored that function to be clearer, and added a test to cover. I made sure the test was failing before this PR ;) Fixes #1891, #1960. cc @filipesilva @ericjim @chalin - See similar #1972 * cleanup
…gular#1987) * fix(find-lazy-modules): Allow for any valid keys/value to be used and properly understand and return the modules in this case. Also refactored that function to be clearer, and added a test to cover. I made sure the test was failing before this PR ;) Fixes angular#1891, angular#1960. cc @filipesilva @ericjim @chalin - See similar angular#1972 * cleanup
Fixed in caa3142 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Windows 7
ng --version
. If there's nothing outputted, please runin a Terminal:
node --version
and paste the result here:angular-cli: 1.0.0-beta.11-webpack.8
node: 6.5.0
os: win32 x64
do on your code? etc.
As per #1922 followed @SeekingMonkey instructions and it all worked fine.
Copies newly created files (including node_modules/ to existing project).
Ran ng-serve still worked just fine.
Migrate existing app into src/app and all worked fine.
Used Ctl + C to exit ng-serve
Tried doing ng-build and get the error.
more information.
Unexpected token ' in JSON at position 0
SyntaxError: Unexpected token ' in JSON at position 0
at Object.parse (native)
at C:\Git\insight-frontend\node_modules\angular-cli\addon\ng2\models\find-lazy-modules.ts:29:21
at Array.map (native)
at findLoadChildren (C:\Git\insight-frontend\node_modules\angular-cli\addon\ng2\models\find-lazy-modules.ts:28:10)
at C:\Git\insight-frontend\node_modules\angular-cli\addon\ng2\models\find-lazy-modules.ts:48:9
at Array.forEach (native)
at Object.findLazyModules (C:\Git\insight-frontend\node_modules\angular-cli\addon\ng2\models\find-lazy-modules.ts:47:10)
at Object.getWebpackCommonConfig (C:\Git\insight-frontend\node_modules\angular-cli\addon\ng2\models\webpack-build-common.ts:18:43)
at new NgCliWebpackConfig (C:\Git\insight-frontend\node_modules\angular-cli\addon\ng2\models\webpack-config.ts:13:30)
at Class.run (C:\Git\insight-frontend\node_modules\angular-cli\addon\ng2\tasks\build-webpack.ts:16:22)
at Class.run (C:\Git\insight-frontend\node_modules\angular-cli\addon\ng2\commands\build.ts:49:26)
at Class. (C:\Git\insight-frontend\node_modules\angular-cli\lib\models\command.js:152:17)
at lib$rsvp$$internal$$tryCatch (C:\Git\insight-frontend\node_modules\rsvp\dist\rsvp.js:1036:16)
at lib$rsvp$$internal$$invokeCallback (C:\Git\insight-frontend\node_modules\rsvp\dist\rsvp.js:1048:17)
at C:\Git\insight-frontend\node_modules\rsvp\dist\rsvp.js:331:11
at lib$rsvp$asap$$flush (C:\Git\insight-frontend\node_modules\rsvp\dist\rsvp.js:1198:9)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
Issue seems to be after doing the ng-serve and then exiting, so very strange this is happening after that point when you try to do another build/serve.
The text was updated successfully, but these errors were encountered: