Eading time: 6 minutes share: february 10, 2022 written by dominik kundel twilion darragh o'connor twilion reviewed by ayanna julien twilion working with environment variables in node.js working with environment variables is a great way to configure different aspects of your node.js application . , aws, now.sh, etc.) and node.js modules use environment variables.
Debugging we all know that moment when 11-digit phone number format philippines things aren't working the way we want them to and a module isn't doing what it's supposed to. That's when it's time to debug. One strategy that has helped me a lot is to use the environment variable debug to get more detailed logs for a group of modules. For example, if you take a express basic server like this: javascript copy the code const app = require('express')(); const bodyparser = require('body-parser'); app.
Use(bodyparser.json()); // for parsing application/json app.use(bodyparser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded app.post('/', (req, res, next) => { console.log(req); }); app.listen(3000); and you run it with the variable debug set to * : bash copy the code debug=* node server.js you will receive a series of detailed logs that look like this: logs the "magic" is done with a lightweight module called debug that is extremely easy to use.
own characteristics, strengths
-
- Posts: 14
- Joined: Sun Dec 22, 2024 6:07 am