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.

Is there a way to setup node environment when window global is present?

See original GitHub issue

Hi, so you are deciding between browser or node environment based on presence of window variable:

if (_window) {
  setupBrowser();
} else {
  setupNode();
}

where _window is

'undefined' !== typeof window ? window : null

We have a window global in node though and we would like to have the node part with crypto.randomBytes available. So we get rid of:

[SECURITY] node-uuid: crypto not usable, falling back to insecure Math.random()

Is there any workaround for this? Or are you willing to change the “decision” part for node to be more complex than just window being undefined? (e.g. having a window.iAmStillNode set to true or something more complex)

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:8
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
shankie-codescommented, Feb 23, 2017

FWIW, I’m having this come through as a warning when running tests in Jest.

0reactions
coolaj86commented, Oct 14, 2016

If someone wants to PR I can pull it in.

I’d rather try { setupNode(); } catch (e) { setupBrowser() } because depending on window.self just sounds like we’re gonna land in trouble somehow somewhere.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - How can I set NODE_ENV=production on Windows?
Just install it (globally), and run your npm script commands, it should automatically make them work. Save this answer. Show activity on this...
Read more >
How to Set Up Windows for Node.js Development with NVM
Unzip the folder's contents and run nvm-setup.exe . You'll be prompted to agree with the project's terms of use (currently it's the MIT...
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 >
Node JS Environment Setup - Node.js installation - DigitalOcean
Choose Default values and click on “Install” Button. Open Node JS Platform Home in your Explorer. Here we can observe node.exe and npm....
Read more >
Setting up a Node development environment - MDN Web Docs
In order to use Express you will first have to install Nodejs and the Node Package Manager (npm) on your operating system. The...
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