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

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.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 2
  • Comments: 38 (16 by maintainers)

Most upvoted comments

still an issue in 0.28.0

screen

+1 for 0.28

44af0d3dec53b6e01af9e8bc9b0254a5d03846a0 is the fix 😃

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

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.