Why is process.env.NODE_ENV undefined?
process.env is a reference to your environment, so you have to set the variable there. To set an environment variable in Windows: on macOS / OS X or Linux:
process.env is a reference to your environment, so you have to set the variable there. To set an environment variable in Windows: on macOS / OS X or Linux:
window is a browser thing that doesn’t exist on Node. If you really want to create a global, use global instead: global is Node’s identifier for the global object, like window is on browsers. But, there’s no need to create truly global variables in Node programs. Instead, just create a module global: …and since you include it in your exports, other modules can … Read more
This command fix the issue. It worked for me:
I recently got this socket hang up problem. I researched for a few days until I found a solution that worked for me. So, maybe this can help. It worked for me to add the http(s)Agent property with keepAlive: true in creating the http client. Here’s an example of what it might look like: This property is responsible for managing the … Read more
Update Since Node v12 (April 2019), support for ES modules is enabled by default, and since Node v15 (October 2020) it’s stable (see here). Files including node modules must either end in .mjs or the nearest package.json file must contain “type”: “module”. The Node documentation has a ton more information, also about interop between CommonJS and ES modules. Performance-wise there is always the … Read more
Windows Machine: Need to kill a Node.js server, and you don’t have any other Node processes running, you can tell your machine to kill all processes named node.exe. That would look like this: And if the processes still persist, you can force the processes to terminate by adding the /f flag: If you need more fine-grained control and … Read more
npm E A quick solution from the internet search was npm config set strict-ssl false, luckily it worked. But as a part of my work environment, I am restricted to set the strict-ssl flag to false. Later I found a safe and working solution, this worked perfectly and I got a success message Happy Hacking! by not setting … Read more
I’m building a web scraper with Node and Cheerio, and for a certain website I’m getting the following error (it only happens on this one website, no others that I try to scrape. It happens at a different location every time, so sometimes it’s url x that throws the error, other times url x is fine and it’s a … Read more
My server threw this today, which is a Node.js error I’ve never seen before: I’m wondering if this is related to the DynDns DDOS attack which affected Shopify and many other services today. Here’s an article about that. My main question is what does dns.js do? What part of node is it a part of? How can I … Read more
This simple diagram will help you understand the difference between require and import. Apart from that, You can’t selectively load only the pieces you need with require but with import, you can selectively load only the pieces you need, which can save memory. Loading is synchronous(step by step) for require on the other hand import can be asynchronous(without waiting for previous import) so it can perform a little better … Read more