简体   繁体   中英

React Native: Platform specific code in package.json

I want to use expo 32 for iOS, but expo 31 for Android. Like so:

"expo": Platform.OS === 'ios' ? "^32.0.0" : "^31.0.4"

What would be a good way to do that in a json file?

As far as I know this feature doesn't exist. They do have an os specifier in docs which may help to some degree but doesn't solve the exact problem you're having.

os specifier: https://docs.npmjs.com/files/package.json#os

There is also an external npm package with a similar feature here:

https://www.npmjs.com/package/npm-platform-dependencies

Finally, I was also able to find this previous post with some suggestions that may be of use to you, one of the answers someone recommended install scripts.

npm package.json OS specific dependency

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM