Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] process.env - Cannot read properties of undefined (reading 'env') #1399

Open
RareSecond opened this issue Aug 17, 2023 · 2 comments
Open
Labels
bug help wanted You Can Do This This idea is well spec'd and ready for a PR

Comments

@RareSecond
Copy link

Describe the bug
Using process.env.whatever in a danger file leads to a runtime error stating that process is undefined.

To Reproduce

  1. Create a dangerfile
  2. Add a reference to process.env
  3. See the error

Expected behavior
You should be able to access process.env

Screenshots
CleanShot 2023-08-17 at 08 08 11

Your Environment

software version
danger.js 11.2.0
node node:16 docker image
npm 7.11.0 (pnpm)
Operating System Gitlab CI

Additional context
Add any other context about the problem here.

@RareSecond RareSecond added the bug label Aug 17, 2023
@orta
Copy link
Member

orta commented Aug 17, 2023

Huh, interesting, I wonder how 6 years down the line you're the first to hit this.

Maybe part of initial security models block certain globals, I thought that was all removed though when running locally - you're welcome to take a look 👍🏻

@orta orta added help wanted You Can Do This This idea is well spec'd and ready for a PR labels Aug 17, 2023
@ashfurrow
Copy link
Member

For what it's worth, I am able to access the process.env.MY_ENV_VARIABLE successfully. I'm running this on Danger 12.3.3 via a GitHub Action. However, TypeScript is unhappy about the undeclared process global, which I would normally fix by adding @types/node as a dev dependency. That wouldn't work for me (because I'm executing this on a GitHub Action) so I added a @ts-expect-error comment:

// @ts-expect-error Danger can't reference @types/node for the `process` type in a GitHub Action, so we ignore this error instead.
const myEnvVariable = process.env.MY_ENV_VARIABLE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help wanted You Can Do This This idea is well spec'd and ready for a PR
Projects
None yet
Development

No branches or pull requests

3 participants