【问题标题】:how to use react-native-config to set environment variable in nx?如何使用react-native-config 在nx 中设置环境变量?
【发布时间】:2022-12-19 23:07:17
【问题描述】:

我想使用 react-native-config 通过 nx 设置环境变量。是否可以将这两个包组合在一起以实现目标?或者只使用 nx 环境变量设置。任何建议表示赞赏。谢谢。

我想使用 @nrwl/workspace:run-commands 来运行我的自定义脚本。

 "customCommand": {
   "executor": "nx:run-commands",
   "options": {
      "command": "react-native run-android"
   }
 }

当我在命令行中运行命令时。

npx nx run employee:make

它显示以下错误

TypeError: Cannot read properties of undefined (reading 'options')

【问题讨论】:

    标签: react-native monorepo


    【解决方案1】:

    不确定要在库或应用程序中运行。我假设您尝试在库中运行命令。你的 project.json 看起来像这样:

    {
      "$schema": "../../node_modules/nx/schemas/project-schema.json",
      "sourceRoot": "libs/assets/src",
      "projectType": "library",
      "tags": [],
      "targets": {
        "lint": {
          "executor": "@nrwl/linter:eslint",
          "outputs": ["{options.outputFile}"],
          "options": {
            "lintFilePatterns": ["libs/assets/**/*.{ts,tsx,js,jsx}"]
          }
        },
        "test": {
          "executor": "@nrwl/jest:jest",
          "outputs": ["coverage/libs/assets"],
          "options": {
            "jestConfig": "libs/assets/jest.config.ts",
            "passWithNoTests": true
          }
        }
      }
    }
    
    

    并添加您的命令:

    {
      "$schema": "../../node_modules/nx/schemas/project-schema.json",
      "sourceRoot": "libs/assets/src",
      "projectType": "library",
      "tags": [],
      "targets": {
        "customCommand": {
          "executor": "nx:run-commands",
          "options": {
            "command": "react-native run-android"
          }
        },
        "lint": {
          "executor": "@nrwl/linter:eslint",
          "outputs": ["{options.outputFile}"],
          "options": {
            "lintFilePatterns": ["libs/assets/**/*.{ts,tsx,js,jsx}"]
          }
        },
        "test": {
          "executor": "@nrwl/jest:jest",
          "outputs": ["coverage/libs/assets"],
          "options": {
            "jestConfig": "libs/assets/jest.config.ts",
            "passWithNoTests": true
          }
        }
      }
    }
    
    

    使用以下命令运行命令:

    nx run assets:customCommand
    

    【讨论】:

      猜你喜欢
      • 2016-01-12
      • 2022-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-02
      • 2023-02-24
      • 1970-01-01
      • 2019-03-24
      • 2021-10-25
      相关资源
      最近更新 更多