如何在Windows 10中的用户环境变量中设置多个路径

时间:2019-04-22 16:19:17

标签: node.js react-native windows-10 environment-variables

我想在Windows 10的用户环境变量中设置多个路径,但只能设置一个路径,如何克服这个问题?

1 个答案:

答案 0 :(得分:0)

如果要添加用户定义的环境变量,请使用react-native-config库。简而言之,如果.env文件中定义了变量,那么您可以在react-native应用程序中的任何地方使用它,如下所示:-

.env文件

  

API_URL =“ https://baseurl/endpoint

//要使用上述环境变量

  

导入配置react-native-config

     

function apiCall(){axios(config)}

借助react-native-config,您还可以在本机代码中使用环境变量,反之亦然。

为了更好地使用,请定义.env.staging文件。默认情况下,config lib查找.env文件。要使用.env.staging文件运行应用程序,请参见以下命令。

  

$ ENVFILE = .env.staging react-native run-ios#bash

     

$ SET ENVFILE = .env.staging && react-native run-ios#windows

     

$ env:ENVFILE =“。env.staging”; react-native run-ios#powershell

有关更多信息,请参见结帐:-https://github.com/luggit/react-native-config

快乐的编码伙伴:)

相关问题