Skip to content
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

React packager failing - SyntaxError: Unexpected end of input #47

Closed
ColinEberhardt opened this issue Feb 6, 2015 · 16 comments
Closed
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@ColinEberhardt
Copy link

Unfortunately I am having issues with getting the movies example app working :-(

I have installed watchman as per the instructions, and already had node v0.10.36 installed.

On running npm start all seems well. However when I load the movies example it fails.

Testing via the URL:

http://localhost:8081/Examples/Movies/MoviesApp.includeRequire.runModule.bundle

Yields the following error:

{"type":"InternalError","message":"React packager has encountered an internal error, please check your terminal error output for more details"}

And here is the terminal output:

$ npm start

> [email protected] start /Users/colineberhardt/Projects/react-native
> ./packager/packager.sh


 ===============================================================
 |  Running packager on port 8081.       
 |  Keep this packager running while developing on any JS         
 |  projects. Feel free to close this tab and run your own      
 |  packager instance if you prefer.                              
 |                                                              
 |     https://github.com/facebook/react-native                 
 |                                                              
 ===============================================================


React packager ready.

SyntaxError: Unexpected end of input
    at Object.parse (native)
    at /Users/colineberhardt/Projects/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js:270:32
    at _fulfilled (/Users/colineberhardt/Projects/react-native/node_modules/q/q.js:787:54)
    at self.promiseDispatch.done (/Users/colineberhardt/Projects/react-native/node_modules/q/q.js:816:30)
    at Promise.promise.promiseDispatch (/Users/colineberhardt/Projects/react-native/node_modules/q/q.js:749:13)
    at /Users/colineberhardt/Projects/react-native/node_modules/q/q.js:557:44
    at flush (/Users/colineberhardt/Projects/react-native/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:442:13)
[17:52:41] <START> find dependencies

I've had a poke around DependencyGraph and tried to add some logging but haven't made much progress.

Has anyone else ecountered (and maybe solved!) this issue?

@vjeux
Copy link
Contributor

vjeux commented Feb 6, 2015

cc @amasad

@jimjeffers
Copy link

I'm running into the same issue here. Here are my local node and npm versions just for reference:

→ npm -v
2.1.7

→ node -v
v0.10.33

@amasad
Copy link
Contributor

amasad commented Feb 7, 2015

That failure is at a line where it's trying to JSON.parse a package.json file. I'm looking into this now but do you have any custom node module that may have a malformed package.json?

@amasad
Copy link
Contributor

amasad commented Feb 7, 2015

@ColinEberhardt
Copy link
Author

Thanks @amasad - this is the strange thing, when I add a console.log ...

      .then(function(content) {
        console.log(content);
        var packageJson = JSON.parse(content);

I observe the following:

--- snip lots of package.json output above ---
{
    "main" : "./lib"
}

SyntaxError: Unexpected end of input
    at Object.parse (native)
    at /Users/colineberhardt/Projects/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js:271:32
    at _fulfilled (/Users/colineberhardt/Projects/react-native/node_modules/q/q.js:787:54)
    at self.promiseDispatch.done (/Users/colineberhardt/Projects/react-native/node_modules/q/q.js:816:30)
    at Promise.promise.promiseDispatch (/Users/colineberhardt/Projects/react-native/node_modules/q/q.js:749:13)
    at /Users/colineberhardt/Projects/react-native/node_modules/q/q.js:557:44
    at flush (/Users/colineberhardt/Projects/react-native/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:442:13)
[20:29:18] <START> find dependencies

i.e. it outputs lots of package.json output, all of which looks fine. Then it hits the error but I don't see content in the console log.

I've added logging to try and determine which file is causing issues:

    if (packagePath != null) {
      console.log('opening package: ' + packagePath);
      return readFile(packagePath, 'utf8')
        .then(function(content) {
          console.log('opened package: ' + packagePath);
          var packageJson = JSON.parse(content);

On npm start I see a whole lot of logging, ending as follows:

opening package: /Users/colineberhardt/Projects/react-native/node_modules/react-tools/node_modules/commoner/node_modules/recast/node_modules/source-map/node_modules/amdefine/package.json
opened package: /Users/colineberhardt/Projects/react-native/node_modules/react-tools/node_modules/commoner/node_modules/recast/node_modules/source-map/node_modules/amdefine/package.json
opening package: /Users/colineberhardt/Projects/react-native/node_modules/module-deps/node_modules/browser-resolve/node_modules/resolve/test/resolver/biz/node_modules/garply/package.json
opened package: /Users/colineberhardt/Projects/react-native/node_modules/module-deps/node_modules/browser-resolve/node_modules/resolve/test/resolver/biz/node_modules/garply/package.json

Then as soon as I hit the URL in the browser, the following error is logged:

SyntaxError: Unexpected end of input
    at Object.parse (native)
    at /Users/colineberhardt/Projects/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js:272:32
    at _fulfilled (/Users/colineberhardt/Projects/react-native/node_modules/q/q.js:787:54)
    at self.promiseDispatch.done (/Users/colineberhardt/Projects/react-native/node_modules/q/q.js:816:30)
    at Promise.promise.promiseDispatch (/Users/colineberhardt/Projects/react-native/node_modules/q/q.js:749:13)
    at /Users/colineberhardt/Projects/react-native/node_modules/q/q.js:557:44
    at flush (/Users/colineberhardt/Projects/react-native/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:442:13)
[20:34:18] <START> find dependencies

I'm a bit baffled as i would have expected some logging before the error to indicate which package.json it was opening.

Confused!

@vjeux
Copy link
Contributor

vjeux commented Feb 7, 2015

@amasad would be nice to add a proper error message if a package.json file is malformed

@amasad
Copy link
Contributor

amasad commented Feb 7, 2015

It seems like it's choking on some test package.json files. I think we should ignore malformed package.json and just warn when building the dependency graph. Once the user require that module will figure out that something is wrong.

@amasad
Copy link
Contributor

amasad commented Feb 7, 2015

@ColinEberhardt will land a fix soon but try this for now:

-        var packageJson = JSON.parse(content);
-        if (packageJson.name == null) {
+        var packageJson;
+        try {
+          packageJson = JSON.parse(content);
+        } catch (e) {
+          debug('WARNING: malformed package.json: ', packagePath);
+          return q();
+        }

@ColinEberhardt
Copy link
Author

Thanks @amasad - here's the culprit:

WARNING: malformed package.json:  /Users/colineberhardt/Projects/react-native/node_modules/npm/test/fixtures/config/package.json

@amasad
Copy link
Contributor

amasad commented Feb 7, 2015

Interesting, why do you have npm in mode_modules? Do we require it as a
dependency?

Regardless, will land the fix to ignore these malformed packages.

On Saturday, February 7, 2015, Colin Eberhardt [email protected]
wrote:

Thanks @amasad https://github.com/amasad - here's the culprit:

WARNING: malformed package.json: /Users/colineberhardt/Projects/react-native/node_modules/npm/test/fixtures/config/package.json


Reply to this email directly or view it on GitHub
#47 (comment)
.

@ColinEberhardt
Copy link
Author

Ahhhh!!! Found the issue - I mistakenly cut and paste the instructions from the README:

npm install npm start

Note, the lack of line-break, which causes an npm install npm. Must have just been running on auto-pilot!

@amasad
Copy link
Contributor

amasad commented Feb 7, 2015

Haha no worries at all. Thanks for exposing this bug

On Saturday, February 7, 2015, Colin Eberhardt [email protected]
wrote:

Ahhhh!!! Found the issue - I mistakenly cut and paste the instructions
from the README:

npm install npm start

Note, the lack of line-break, which causes an npm install npm. Must have
just been running on auto-pilot!


Reply to this email directly or view it on GitHub
#47 (comment)
.

@vjeux
Copy link
Contributor

vjeux commented Feb 12, 2015

We fixed both the README and the error message. Thanks for this!

@vjeux vjeux closed this as completed Feb 12, 2015
dustturtle added a commit to dustturtle/react-native that referenced this issue Jul 6, 2016
…crash on simulator, on device I got nothing but app freezed)!

My app has an old version of JSONKit which is still using MRC. I think JSONKit is not needed if system version is available. Kicking out of JSONKit will make react native stronger.
Crash stack:
* thread facebook#11: tid = 0xbd672f, 0x000000010a10edeb imobii-waiqin`jk_encode_add_atom_to_buffer(encodeState=0x00007f9b820a1000, objectPtr=22 key/value pairs) + 16971 at JSONKit.m:2807, name = 'com.facebook.React.JavaScript', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
    frame #0: 0x000000010a10edeb imobii-waiqin`jk_encode_add_atom_to_buffer(encodeState=0x00007f9b820a1000, objectPtr=22 key/value pairs) + 16971 at JSONKit.m:2807
    frame facebook#1: 0x000000010a10ef67 imobii-waiqin`jk_encode_add_atom_to_buffer(encodeState=0x00007f9b820a1000, objectPtr=2 key/value pairs) + 17351 at JSONKit.m:2811
    frame facebook#2: 0x000000010a10ef67 imobii-waiqin`jk_encode_add_atom_to_buffer(encodeState=0x00007f9b820a1000, objectPtr=25 key/value pairs) + 17351 at JSONKit.m:2811
    frame facebook#3: 0x000000010a10e768 imobii-waiqin`jk_encode_add_atom_to_buffer(encodeState=0x00007f9b820a1000, objectPtr=@"3 elements") + 15304 at JSONKit.m:2778
  * frame facebook#4: 0x000000010a10a26a imobii-waiqin`-[JKSerializer serializeObject:options:encodeOption:block:delegate:selector:error:](self=0x00007f9b831fbc80, _cmd="serializeObject:options:encodeOption:block:delegate:selector:error:", object=@"3 elements", optionFlags=0, encodeOption=10, block=0x0000000000000000, delegate=0x0000000000000000, selector=<no value available>, error=domain: class name = NSInvocation - code: 0) + 2250 at JSONKit.m:2876
    frame facebook#5: 0x000000010a109992 imobii-waiqin`+[JKSerializer serializeObject:options:encodeOption:block:delegate:selector:error:](self=JKSerializer, _cmd="serializeObject:options:encodeOption:block:delegate:selector:error:", object=@"3 elements", optionFlags=0, encodeOption=10, block=0x0000000000000000, delegate=0x0000000000000000, selector=<no value available>, error=domain: class name = NSInvocation - code: 0) + 178 at JSONKit.m:2831
    frame facebook#6: 0x000000010a10f700 imobii-waiqin`-[NSArray(self=@"3 elements", _cmd="JSONStringWithOptions:error:", serializeOptions=0, error=domain: class name = NSInvocation - code: 0) JSONStringWithOptions:error:] + 112 at JSONKit.m:2985
    frame facebook#7: 0x000000010ac13c02 imobii-waiqin`_RCTJSONStringifyNoRetry(jsonObject=@"3 elements", error=domain: class name = NSInvocation - code: 0) + 338 at RCTUtils.m:49
    frame facebook#8: 0x000000010ac13990 imobii-waiqin`RCTJSONStringify(jsonObject=@"3 elements", error=0x0000000000000000) + 128 at RCTUtils.m:77
    frame facebook#9: 0x000000010ab5fdfa imobii-waiqin`__27-[RCTContextExecutor setUp]_block_invoke_2(.block_descriptor=<unavailable>, moduleName=@"UIManager") + 218 at RCTContextExecutor.m:363
    frame facebook#10: 0x00000001134495cc CoreFoundation`__invoking___ + 140
    frame facebook#11: 0x000000011344941e CoreFoundation`-[NSInvocation invoke] + 286
    frame facebook#12: 0x000000010db13db3 JavaScriptCore`JSC::ObjCCallbackFunctionImpl::call(JSContext*, OpaqueJSValue*, unsigned long, OpaqueJSValue const* const*, OpaqueJSValue const**) + 451
    frame facebook#13: 0x000000010db13926 JavaScriptCore`JSC::objCCallbackFunctionCallAsFunction(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSValue*, unsigned long, OpaqueJSValue const* const*, OpaqueJSValue const**) + 262
    frame facebook#14: 0x000000010db14bad JavaScriptCore`long long JSC::APICallbackFunction::call<JSC::ObjCCallbackFunction>(JSC::ExecState*) + 573
    frame facebook#15: 0x000000010dade340 JavaScriptCore`JSC::LLInt::setUpCall(JSC::ExecState*, JSC::Instruction*, JSC::CodeSpecializationKind, JSC::JSValue, JSC::LLIntCallLinkInfo*) + 528
    frame facebook#16: 0x000000010dae535d JavaScriptCore`llint_entry + 22900
    frame facebook#17: 0x000000010dadf7d9 JavaScriptCore`vmEntryToJavaScript + 326
    frame facebook#18: 0x000000010d9b1959 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 169
    frame facebook#19: 0x000000010d9985ad JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 493
    frame facebook#20: 0x000000010d76cb7e JavaScriptCore`JSC::call(JSC::ExecState*, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 62
    frame facebook#21: 0x000000010d929a55 JavaScriptCore`JSC::callGetter(JSC::ExecState*, JSC::JSValue, JSC::JSValue) + 149
    frame facebook#22: 0x000000010dad49fb JavaScriptCore`llint_slow_path_get_by_id + 2203
    frame facebook#23: 0x000000010dae22f0 JavaScriptCore`llint_entry + 10503
    frame facebook#24: 0x000000010dae5368 JavaScriptCore`llint_entry + 22911
    frame facebook#25: 0x000000010dae52fd JavaScriptCore`llint_entry + 22804
    frame facebook#26: 0x000000010dae5368 JavaScriptCore`llint_entry + 22911
    frame facebook#27: 0x000000010dae5368 JavaScriptCore`llint_entry + 22911
    frame facebook#28: 0x000000010dae52fd JavaScriptCore`llint_entry + 22804
    frame facebook#29: 0x000000010dae5368 JavaScriptCore`llint_entry + 22911
    frame facebook#30: 0x000000010dae5368 JavaScriptCore`llint_entry + 22911
    frame facebook#31: 0x000000010dae5368 JavaScriptCore`llint_entry + 22911
    frame facebook#32: 0x000000010dae552a JavaScriptCore`llint_entry + 23361
    frame facebook#33: 0x000000010dae5368 JavaScriptCore`llint_entry + 22911
    frame facebook#34: 0x000000010dae5368 JavaScriptCore`llint_entry + 22911
    frame facebook#35: 0x000000010dadf7d9 JavaScriptCore`vmEntryToJavaScript + 326
    frame facebook#36: 0x000000010d9b1959 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 169
    frame facebook#37: 0x000000010d998264 JavaScriptCore`JSC::Interpreter::execute(JSC::ProgramExecutable*, JSC::ExecState*, JSC::JSObject*) + 10404
    frame facebook#38: 0x000000010d7a8786 JavaScriptCore`JSC::evaluate(JSC::ExecState*, JSC::SourceCode const&, JSC::JSValue, WTF::NakedPtr<JSC::Exception>&) + 470
    frame facebook#39: 0x000000010d9f6fb8 JavaScriptCore`JSEvaluateScript + 424
    frame facebook#40: 0x000000010ab6379e imobii-waiqin`__68-[RCTContextExecutor executeApplicationScript:sourceURL:onComplete:]_block_invoke.264(.block_descriptor=<unavailable>) + 414 at RCTContextExecutor.m:589
    frame facebook#41: 0x000000010ab63262 imobii-waiqin`__68-[RCTContextExecutor executeApplicationScript:sourceURL:onComplete:]_block_invoke(.block_descriptor=<unavailable>) + 498 at RCTContextExecutor.m:589
    frame facebook#42: 0x000000010ab63df8 imobii-waiqin`-[RCTContextExecutor executeBlockOnJavaScriptQueue:](self=0x00007f9b832f6040, _cmd="executeBlockOnJavaScriptQueue:", block=0x00007f9b80c92970) + 248 at RCTContextExecutor.m:627
    frame facebook#43: 0x000000010eb1d7a7 Foundation`__NSThreadPerformPerform + 283
    frame facebook#44: 0x0000000113486301 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    frame facebook#45: 0x000000011347c22c CoreFoundation`__CFRunLoopDoSources0 + 556
    frame facebook#46: 0x000000011347b6e3 CoreFoundation`__CFRunLoopRun + 867
    frame facebook#47: 0x000000011347b0f8 CoreFoundation`CFRunLoopRunSpecific + 488
    frame facebook#48: 0x000000010ab5e41b imobii-waiqin`+[RCTContextExecutor runRunLoopThread](self=RCTContextExecutor, _cmd="runRunLoopThread") + 363 at RCTContextExecutor.m:284
    frame facebook#49: 0x000000010ebc012b Foundation`__NSThread__start__ + 1198
    frame facebook#50: 0x00000001140869b1 libsystem_pthread.dylib`_pthread_body + 131
    frame facebook#51: 0x000000011408692e libsystem_pthread.dylib`_pthread_start + 168
    frame facebook#52: 0x0000000114084385 libsystem_pthread.dylib`thread_start + 13
@Haroenv
Copy link

Haroenv commented Aug 6, 2017

I have this error message without a path, did something get reverted?

Problem checking node_modules dependencies: Unexpected end of JSON input

@joshkarges
Copy link

I have @Haroenv's same issue.

@yemarnevets
Copy link

yemarnevets commented Feb 22, 2018

I did a complete fresh install from the guide: https://facebook.github.io/react-native/docs/getting-started.html and I'm still running into this issue. The error message is quite cryptic. I'd hope for more detail in development mode. "07:53:10: Problem checking node_modules dependencies: Unexpected end of JSON input"

@facebook facebook locked as resolved and limited conversation to collaborators May 29, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

8 participants