React-native: [Packager] child "platform" fails because ["platform" is required]

Created on 12 Sep 2015  路  38Comments  路  Source: facebook/react-native

Create new app with react-native-cli, update package.json to "react-native": "facebook/react-native" rerun npm i and get:

[5:32:17 PM] <END>   Building Dependency Graph (2999ms)
Error: Error validating module options: child "platform" fails because ["platform" is required]
    at /test/node_modules/react-native/packager/react-packager/src/lib/declareOpts.js:60:13
    at /test/node_modules/react-native/packager/react-packager/src/Server/index.js:161:20
    at tryCallOne (/test/node_modules/react-native/node_modules/promise/lib/core.js:37:12)
    at /test/node_modules/react-native/node_modules/promise/lib/core.js:103:15
    at flush (/test/node_modules/react-native/node_modules/promise/node_modules/asap/raw.js:50:29)
    at doNTCallback0 (node.js:407:9)
    at process._tickCallback (node.js:336:13)
[5:34:52 PM] <START> request:/index.ios.bundle

This is on Xcode 7 GM. I understand master isn't meant to be as stable as a release or rc build, so not sure if a compile time error like this is within the norm.

Locked

Most helpful comment

still an issue in 0.28.0

screen

All 38 comments

cc @foghina

A bit of debugging traced back to this line:
https://github.com/facebook/react-native/blob/master/packager/react-packager/src/Server/index.js#L410

  _getOptionsFromUrl(reqUrl) {
   // ...
    return {
      // ...
      platform: urlObj.query.platform,
    };
  }

I'm assuming this is in flux to support android. For others that come across this issue, simply adding a platform param to the querystring in AppDelegate.m will get you going again:

jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios"];

Although I haven't tried using react-native bundle yet, which also may need some help.

Thanks @sjmueller. updating jsCodeLocation to add the platform query string fixed the issue.

This isn't an issue anymore with 0.11.0 :)

This is still an issue with 0.11.0 if using Option 2 in AppDelegate.m. The curl command needs to have the platform option added. At least it worked for me.

This is still an issue with 0.11.0 if using Option 2 in AppDelegate.m

Can someone send a PR to update the comment?

My issue was in building UIExplorer. I see that the AppDelegate.m template in local-cli/generator-ios/templates/app no longer advises curl, but specifies react-native bundle instead. So it appears the AppDelegate.m in the Examples is not getting updated when the main template is changed. Perhaps there should be a process for this?

The instructions for bundling should eventually stabilize so I think manual upkeep is the cheapest option. We should update the comments.

Oh I see. Each AppDelegate.m is quite different in the Examples, so it's not just a matter of copying the template over. So... When I try to run react-native bundle in react-native/Examples/UIExplorer I get the error:

$ react-native bundle
Command `bundle` unrecognized. Did you mean to run this inside a react-native project?

and react-native bundle does work in my other project. So does this mean the structure of the examples is older and the comment should still advise the curl command?

I experienced this when running the example, but then keeping the packager running while moving over to a newly-created app from the generator.

I've just updated my project from 0.11.4 to 0.12.0-rc and this issue has returned.
Adding the platform query still temporarily fixes the issue.

Yeah, me2, 0.12.0-rc seems a bit too beta to deserve the rc tag.

I'm seeing the same issue in 0.12.0-rc. Editing AppDelegate.m as mentioned above (adding ?platform=ios) fixes the problem for me.

@martinbigio, @amasad is there a reason packager can't infer platform from url extension? It definitely used to do this in the past.

I like the idea of inferring the platform if the index file contains ios/android, and still requiring platform if you have only index.js.

Alternatively it would be consistent with how the rest of the packager works if you could never reference index.ios.js and index.android.js, and always had to reference index.js + provide platform.

+1 in 0.12.x

as a temporary patch I've opened up node_modes/react-native/packager/react-packager/src/Server/index.js and patched this

  platform: {
    type: 'string',
    required: true,
  }

to this

  platform: {
    type: 'string',
    default: 'ios',
  }

now it compiles and works fine for me

+1 in 0.13.0-rc

+1 in 0.12

+2 in 0.12

Thanks, @MadRabbit - you got me past this issue after the 0.12 upgrade

+1 in 0.12. Needs a fix

I'll work on this as soon as I have some free time, probably tomorrow :)

@martinbigio if you'd share your vision on how it supposed to work, maybe someone could get on the issue and fix it for everyone. i could fix it but it's kind of hard to guess the intention of the change between 0.11 -> 0.12 without knowing the context

@MadRabbit Awesome.. That thing worked.

Btw. this requires a fix.

+1 0.13.1 .... very boring guys

+1 in 0.12

I'm landing a fix now, should get to master in a couple of hours :)

@martinbigio nice

44af0d3dec53b6e01af9e8bc9b0254a5d03846a0 is the fix :)

still an issue in 0.28.0

screen

running into the same issue on 0.28

also running into this issue on 0.28

+1 for 0.28

+1 for ^0.36.1

Was this page helpful?
0 / 5 - 0 ratings