danger / danger/danger-js

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

Open
#1,399 2 comments 0 reactions 0 assignees View on GitHub
bug help wanted You Can Do This
Dominant language
TypeScript
Stars
5.5k
Forks
379
Avg merge
2h 8m
Merged PRs (30d)
6

Description

**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](https://github.com/danger/danger-js/assets/11869830/7f1f4bb0-b704-409f-b67b-4499fd3a561d)

**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.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with a dangerfile that references process.env under the reported Node 16 GitLab CI environment. Trace how dangerfiles are executed and verify that a dangerfile can read process.env without the runtime error; confirm the behavior in a focused test if the project has coverage for this execution path.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
ci-cd, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.