简体   繁体   中英

Error: $VARIABLE is not listed as a dependency in turbo.json

I'm not able to solve an error which is mentioned in the title:

Error: $VARIABLE is not listed as a dependency in turbo.json

When I run npm run build I get errors for 2 variables and not for all of them that's what is strange to me...

Error: $NEXT_STRIPE_SK is not listed as a dependency in turbo.json  turbo/no-undeclared-env-vars
Error: $NEXT_PUBLIC_STRIPE_PK is not listed as a dependency in turbo.json  turbo/no-undeclared-env-vars

turbo.json

{
  "$schema": "https://turbo.build/schema.json",
  "pipeline": {
    "build": {
      "dependsOn": [
        "^build"
      ],
      "outputs": [
        "dist/**",
        ".next/**"
      ]
    },
    "order#build": {
      "dependsOn": [
        "^build"
      ],
      "env": [
        "NEXT_PUBLIC_STRIPE_PK",
        "NEXT_STRIPE_SK"
      ],
      "outputs": [
        ".next/**"
      ]
    },
    "lint": {
      "outputs": []
    },
    "dev": {
      "cache": false
    }
  },
  "globalEnv": [
    "NEXT_PUBLIC_SUPABASE_URL",
    "NEXT_PUBLIC_SUPABASE_ANON_KEY",
    "SUPABASE_SERVICE_ROLE",
    "NEXT_PUBLIC_STRIPE_PK",
    "NEXT_STRIPE_SK"
  ],
  "globalDependencies": [
    "$NEXT_PUBLIC_SUPABASE_URL",
    "$NEXT_PUBLIC_SUPABASE_ANON_KEY",
    "$SUPABASE_SERVICE_ROLE",
    "$NEXT_PUBLIC_STRIPE_PK",
    "$NEXT_STRIPE_SK"
  ]
},

This is my.env.local

NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY=
SUPABASE_SERVICE_ROLE=
NEXT_PUBLIC_STRIPE_PK=
NEXT_STRIPE_SK=

Based on the configuration

A list of file globs for implicit global hash dependencies. The contents of these files will be included in the global hashing algorithm and affect the hashes of all tasks. This is useful for busting the cache based on.env files (not in Git) or any root level file that impacts workspace tasks (but are not represented in the traditional dependency graph (eg a root tsconfig.json, jest.config.js, .eslintrc, etc.)).

you should pass the name of the files to globalDependencies

"globalDependencies": [
    ".env", // contents will impact hashes of all tasks
    ".env.local",
    "tsconfig.json" // contents will impact hashes of all tasks
  ]

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