简体   繁体   中英

How can I use cross-env with expo?

I have an expo app and I would like to use cross-env with expo.

I have changed the start script in package.json to "cross-env LOCAL_IP_ADDRESS=TEST expo start" but the environment variable is not defined once I run npm start .

What am I doing wrong?

Are you trying to use LOCAL_IP_ADDRESS inside of your app? If so, you should follow this guide: https://docs.expo.dev/guides/environment-variables/

What you have done so far only sets the environment variable on the bundler process, it won't be available on your device where your app is running. The guide I linked to explains how to do this.

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