1 min read

error Invalid platform "ios" selected

Today we tried to bundle an old React Native(0.38) project for release:

react-native bundle --verbose --entry-file ./RNindex.js --assets-dest ./RNapp --bundle-output ./RNindex.jsbundle --platform ios --dev false

I got this mysterious error:

error Invalid platform "ios" selected.
info Available platforms are: "native". If you are trying to bundle for an out-of-tree platform, it may not be installed.
error Bundling failed
Error: Bundling failed
    at buildBundle (/Users/muyexi/.config/yarn/global/node_modules/@react-native-community/cli/build/commands/bundle/buildBundle.js:85:11)

After some search I coundn't get a clear anwser, then out of nowhere
I decided to put yarn before the script and had a go, and it works.

yarn react-native bundle --entry-file ./RNindex.js --assets-dest ./RNapp --bundle-output ./RNindex.jsbundle --platform ios --dev false

From React Native CLI, it does say

It exposes react-native binary, so you can call yarn react-native or npx react-native directly from your project.