Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

EXCEPTION: JSON Parse error: Unexpected EOF #42

Closed
ignaciolarranaga opened this issue Dec 24, 2016 · 2 comments
Closed

EXCEPTION: JSON Parse error: Unexpected EOF #42

ignaciolarranaga opened this issue Dec 24, 2016 · 2 comments
Labels

Comments

@ignaciolarranaga
Copy link

Despite it does not prevent the application to start, this strange error appears only on iOS:

Project successfully built
Successfully deployed on device with identifier '00A4117D-42D7-4D34-A741-4D4FAA4286CD'.
CONSOLE LOG file:///app/vendor.ts:null:null: Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.
CONSOLE ERROR file:///app/vendor.ts:null:null: EXCEPTION: JSON Parse error: Unexpected EOF
Dec 24 08:09:43 MacBook-Pro-de-Ignacio hezeaapp[13032]: CONSOLE ERROR file:///app/vendor.js:26786:32: ORIGINAL STACKTRACE:
Dec 24 08:09:43 MacBook-Pro-de-Ignacio hezeaapp[13032]: CONSOLE ERROR file:///app/vendor.js:26787:32: parse@[native code]
	_next@file:///app/vendor.js:16320:39
	next@file:///app/vendor.js:5596:23
	file:///app/vendor.js:46805:40
	invoke@file:///app/vendor.js:45881:33
	onInvoke@file:///app/vendor.js:18568:43
	invoke@file:///app/vendor.js:45880:42
	run@file:///app/vendor.js:45774:49
	file:///app/vendor.js:46140:60
	invokeTask@file:///app/vendor.js:45914:42
	onInvokeTask@file:///app/vendor.js:18559:47
	invokeTask@file:///app/vendor.js:45913:54
	runTask@file:///app/vendor.js:45814:57
	drainMicroTaskQueue@file:///app/vendor.js:46046:42
	promiseReactionJob@[native code]
	UIApplicationMain@[native code]
	start@file:///app/vendor.js:8354:30
	bootstrapApp@file:///app/vendor.js:60192:26
	bootstrapModuleFactory@file:///app/vendor.js:60173:26
	file:///app/bundle.js:2187:139
	__webpack_require__@file:///app/vendor.js:53:34
	webpackJsonpCallback@file:///app/vendor.js:25:42
	anonymous@file:///app/bundle.js:2:13
	evaluate@[native code]
	moduleEvaluation@[native code]
	[native code]
	promiseReactionJob@[native code]
	require@[native code]
	anonymous@file:///app/starter.js:2:8
	evaluate@[native code]
	moduleEvaluation@[native code]
	[native code]
	promiseReactionJob@[native code]

I created an specific fork for easy reproduction that is available here: https://bitbucket.org/ignaciolarranaga/nativescript-webpack-problems.git
Please checkout the tag problem-1 (I might add more issues if I found them)

@ignaciolarranaga
Copy link
Author

While not with exactly the same code (but minor changes any way) I also see the error on Android:

Project successfully built
Successfully deployed on device with identifier 'emulator-5554'.
JS: Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.
JS: EXCEPTION: Unexpected end of JSON input
JS: ORIGINAL STACKTRACE:
JS: SyntaxError: Unexpected end of JSON input
JS:     at Object.parse (native)
JS:     at Response.Body.json (/data/data/com.hezea.ForSaleByOwner/files/app/vendor.js:40233:25)
JS:     at MapSubscriber.project (/data/data/com.hezea.ForSaleByOwner/files/app/bundle.js:2692:46)
JS:     at MapSubscriber._next (/data/data/com.hezea.ForSaleByOwner/files/app/vendor.js:17300:35)
JS:     at MapSubscriber.Subscriber.next (/data/data/com.hezea.ForSaleByOwner/files/app/vendor.js:6044:18)
JS:     at /data/data/com.hezea.ForSaleByOwner/files/app/vendor.js:45464:36
JS:     at ZoneDelegate.invoke (/data/data/com.hezea.ForSaleByOwner/files/app/vendor.js:44470:28)
JS:     at Object.onInvoke (/data/data/com.hezea.ForSaleByOwner/files/app/vendor.js:19889:37)
JS:     at ZoneDelegate.invoke (/data/data/com.hezea.ForSaleByOwner/files/app/vendor.js:44469:34)
JS:     at Zone.run (/data/data/com.hezea.ForSaleByOwner/files/app/vendor.js:44363:43)

I think is more related to the execution than to the code it self, it means, something get wrong while preparing the build or make the lunch of vendors.

@hdeshev
Copy link
Contributor

hdeshev commented Dec 27, 2016

Thanks for sending that project. The error comes from the ng2-translate plugin trying to issue requests and parse localization json files. To fix it, you need two changes:

  1. Add a rule to copy your i18n folder to the device in webpack.common.js. Look for the CopyWebpackPlugin section, and add: { from: "i18n/**" },
  2. Change your translate factory function, so that it uses ~/i18n as the locale files root: return new TranslateStaticLoader(http, "~/i18n");

@hdeshev hdeshev closed this as completed Dec 27, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants