question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

process.env.DEBUG not working?

See original GitHub issue

First, I’m not reopening your recent debate on inline changes to process.env. I support the ability to do so, it just that it doesn’t seem to be working for us anymore.

There are specific cases where the ONLY way to set things is via inline code setting those vars. For us, this is Lambda@Edge which do NOT support env vars as regular functions do.

So for us, this is the only way. The top of our functions look something like this… index.js

process.env.DEBUG = 'logger:*';

const AWS = require('aws-sdk');
const Promise = require('bluebird');
const crypto = require('crypto');
const _ = require('lodash');
const logger = require('../_common/utils/logger');
...

/_common/utils/logger

const debug = require('debug');
const log = debug('logger:logs');
log.log = console.log.bind(console);

module.exports = log;

Note: We are using webpack to bundle our lambda functions (Edge Functions need to be tiny). Not sure if that has anything to do with why it would not work.

This was working previously, and now seems to have stopped working. What are we doing wrong?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
iDVBcommented, Dec 8, 2021

Nm, turns out there is another issue at play unrelated to Debug which may be causing this. I’ll give an update once we sort it out.

Thanks!

On Wed, Dec 8, 2021 at 9:40 AM Qix @.***> wrote:

Without seeing code (and since I don’t use lambdas) it’s really hard to debug. The best advice without more debugging information is what I mentioned before - the assignment needs to come before debug is ever initialized.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/debug-js/debug/issues/815#issuecomment-988872067, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABOIQQOXXBT6FANWINXTADUP5U4HANCNFSM4YLIWS4A .

0reactions
Qix-commented, Dec 8, 2021

Without seeing code (and since I don’t use lambdas) it’s really hard to debug. The best advice without more debugging information is what I mentioned before - the assignment needs to come before debug is ever initialized.

Read more comments on GitHub >

github_iconTop Results From Across the Web

process.env.DEBUG not working? · Issue #815 - GitHub
The problem with assigning to process.env.XXX is order of operations. If you don't modify process.env before you require debug the first ...
Read more >
Why are my custom process.env not working within dotenv?
dotenv file is not loading environment variables. I'm trying to set an env file locally based on process.env.NODE_ENV . The application would be ......
Read more >
Working with Environment Variables in Node.js - Twilio
Environment variables are a great way to configure parts of your Node.js application. Learn how to work with them using helpful tools such ......
Read more >
process.ProcessEnv.DEBUG JavaScript and Node.js code ...
Best JavaScript code snippets using process.ProcessEnv.DEBUG(Showing top 15 results out of 315) · Most used process functions · Popular in JavaScript.
Read more >
process.env variables are not resolved
I have defined my NODE_ENV and PORT in my Run/Debug Configuration, it is working fine, "problem" is that i'm getting a warning that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found