Environment variables not passing through to turbo command as described in documentation #7056
Replies: 6 comments 9 replies
-
|
I don't see anything obviously wrong with your setup. If you don't see the same issue with running |
Beta Was this translation helpful? Give feedback.
-
|
Closing for staleness. |
Beta Was this translation helpful? Give feedback.
-
|
I had the same problem in a Docker image that I use for my Turbo monorepo. The environment variables are not passed to node when I use “turbo run dev” and start all monorepo projects in parallel. The solution was to enter the variables used for the respective script (e. g. dev) in turbo.json, as described in https://turbo.build/repo/docs/crafting-your-repository/using-environment-variables#adding-environment-variables-to-task-hashes. In this example |
Beta Was this translation helpful? Give feedback.
-
|
Hello all |
Beta Was this translation helpful? Give feedback.
-
|
I've found the solution:
|
Beta Was this translation helpful? Give feedback.
-
|
I tried fixing it by loading the path to my root .env file and it worked. Not the best solution but its a good workaround: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've been trying to get
dotenv-cliworking as per the suggested setup on Turborepo's monorepo handbook. I've got the followingpackage.json:{ "name": "xxx-company", "version": "0.0.0", "private": true, "engines": { "node": ">=18.17", "pnpm": ">=8.14" }, "scripts": { "build": "dotenv -- turbo run build", "dev": "dotenv -- turbo run db:connect dev --parallel", "dev:dev": "dotenv -- turbo run db:connect:dev dev --parallel", "dev:prod": "dotenv -- turbo run db:connect:prod dev --parallel", "studio": "dotenv -- turbo run db:connect db:studio --parallel", "studio:dev": "dotenv -- turbo run db:connect:dev db:studio --parallel", "studio:prod": "dotenv -- turbo run db:connect:prod db:studio --parallel", "lint": "dotenv -- turbo run lint", "test": "dotenv -- turbo run test", "clean": "turbo run clean && rimraf node_modules", "pull-envs": "vercel env pull .env", "prepare": "husky install", "preinstall": "npx only-allow pnpm" }, "lint-staged": { "*.{js,jsx,ts,tsx,html,md}": [ "prettier --write --ignore-path .gitignore" ] }, "devDependencies": { "@types/node": "^18.17.8", "dotenv-cli": "latest", "husky": "^8.0.3", "lint-staged": "^15.2.0", "prettier": "^3.2.4", "rimraf": "latest", "turbo": "latest", "vercel": "latest" } }I get a very odd error in my terminal when running
pnpm build,pnpm dev, or any of the other commands withdotenv --:Of course, I could just pass the
--remote-onlyflag, but then I get the same warning about the--summarizeflag. Without attaching every flag that Turborepo's CLI offers, how can I fix this?A few interesting notes/things I've already tried:
npmoryarninstead returns the same resultdotenv ...instead ofdotenv -- ...returns the same resultpnpm devand any other the other commands returns the same result aspnpm build- it's not isolated to thebuildscriptdotenv-cliandturbo1-3 minor versions each returns the same resultnode_modulesfolder and runningpnpm installagain returns the same resultturbo run buildworks perfectly, but then it doesn't include the environment variables in the builddotenv -- pnpx cowsay helloworks perfectly fine, so I don't think this has to do withdotenv-cliso much asturbonot using its default flags correctly when unspecifiedBeta Was this translation helpful? Give feedback.
All reactions