Having trouble getting Node.js DEBUG=appname to work with nodemon on Windows?

I am currently following a Node.js tutorial by Mosh and I'm having trouble getting this line of code to work:

    DEBUG=app:db nodemon index.js

When I try to run it, I encounter the error message:

    'DEBUG' is not recognized as an internal or external command, 
     operable program or batch file.`

It seems to be working fine on his end.

Is this command specific to macOS only? I also attempted to run:

    set DEBUG=app:db nodemon index.js

But encountered the same error.

I've looked at various suggestions and tried them, but nothing seems to work for me. You can check out some answers that I have tried."

If anyone could shed some light on why this isn't working, it would be greatly appreciated.

Answer №1

If you're using Windows, give "set DEBUG=app:* & nodemon index.js" a try. After that, simply refresh your browser and you'll notice the database connection.

Answer №2

When working with windows, it's important to remember that commands must be separated using the && separator:

"scriptCommand": "set DEBUG=app:db&& nodemon index.js"

It is crucial to avoid adding a space between db and &&. The variable space extends all the way to the && wall, which could unintentionally add a space after db to your variable.

If you're looking for a convenient solution, consider using the highly useful cross-env library. This tool allows you to easily declare an environment variable in any operating system (Windows, Mac, Linux) where the project is being developed.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The error thrown by Mongoose, stating "TypeError: Cannot read property 'catch' of undefined," is not caught after the data is saved

After updating to Mongoose version 5.0.15, I encountered an error that says TypeError: Cannot read property 'catch' of undefined when trying to save my object with errors found, even though everything was working fine on Mongoose version 4.13.11. ...

Node Express for Advanced Routing

I'm currently developing a web application that will handle CRUD operations on an array within a collection. Here is the structure of the collection model: var mongoose = require('mongoose'); var website = require('./website'); ...

Issue encountered during the parsing of an expression by MySQLx in a Node.js application

I recently downloaded the @mysql/xDevApi library from the NPM repository at here and it is currently version 1.0.5 Encountering errors when attempting two different methods:- collection.find("$.name == :name") .bind('name','Test') ...

Solution for handling boolean values from mysql database in sequelize

Fetching data from a mysql database to a express rest api app using sequelize as an ORM. When dealing with a BIT(1) value in mysql, sequelize returns it as an instance of buffer object. { "id": 4, "ProductPrice": 12.25, "ProductQuantityOnHand": 0, ...

Executing npm commands programmatically from a node.js script

Currently, I am developing a specialized command line interface (CLI) for managing various packages to be installed or uninstalled using npm. Should I execute npm through spawn('npm') or require('npm')? require('child_process&apos ...

Node.js MySQL REST API query fails to execute

I am developing a login/sign up API using nodejs, express, and mysql. Despite receiving the "Successful Sign Up!" message without any errors during testing, the user table in the database remains empty. Below is the query I am attempting to execute: con. ...

Trouble arises when attempting to parse multiple objects from a JSON file using JavaScript

Encountering JSON parsing issues with multiple JSON objects. JSON data is essential for JavaScript functionality. { "name": "Sara", "age": 23, "gender": "Female", "department": & ...

Configuring headers for all responses in Express.js

While working with Express for web services, I require the responses to be encoded in utf-8. I am aware that I can manually set the charset for each response using the following code: response.setHeader('charset', 'utf-8'); However, ...

Attempting to retrieve the current time using JavaSscript

const currentTime = new Date(); const hours = now.getHours(); Console.log(hours); This block of code is returning an error message... Uncaught ReferenceError: now is not defined Please note that this snippet is written in JavaScript. I attempted to us ...

Optimizing performance by managing numerous network interactions simultaneously using Node.js and mongoDB

If my server app has 1000 records, and for each record, I need to perform two tasks: 1. Conduct a Facebook Graph API request 2. Store the response in mongoDB With all 1000 records ready, can I simply loop through them, make 1000 Facebook API calls, and s ...

Aggregating the outputs of various functions into a single route request and displaying them as HTML in Node.js

Currently diving into the world of nodejs and attempting to run multiple functions in order to output data to html using nodejs, express, and mysql as the backend. The goal is to execute 20 functions with a single routing call, combining the output of thes ...

Challenges Arising from Cross-Origin Resource Sharing in Google Authentication

I've been incorporating Google Auth into my MERN stack web application. Unfortunately, I ran into an issue: When trying to connect to 'http://localhost:5000/api/v1/auth/google' from 'http://localhost:5173', the request was blocked ...

Tips for utilizing UTC time in defining models with Prisma.js and in general in an Express.js project

Is there a way to Run the node.js project in UTC instead of the local timezone? and How can I specify UTC time when defining a model with prisma.js? model Profile { CreatedDate DateTime @default(now()) // but I need it in UTC ModifiedDate DateTi ...

Exploring the method of grouping data by dates in MongoDB

I am in the process of developing a timeline REST API that will retrieve data entries from MongoDB and organize them based on a created_at property within the collection. My goal is to categorize the "timeline" entries into different groups. The first gr ...

Streamline Functional Testing using node.js

After exploring various NPM libraries for testing web pages or web services, I realized that most of them require the server to be running prior to testing. This got me thinking about automating functional testing and setting up an NPM package in a way tha ...

Limiting page entry with passport.js and express middleware

My server is set up to authenticate user login. I have successfully redirected users to the success page after authentication (and back to the login page if it fails). However, I am facing an issue with using my own express middleware to restrict access fo ...

Issues encountered when attempting to write data using a service account access in the Google Sheets API for Node.js

I am utilizing a Google Sheet and successfully reading from it by granting access to a service account. Here is the code snippet for the read operation: // Set up a JWT auth client let jwtClient = new google.auth.JWT( privatekey.client_email, null ...

You cannot reassign NodeJS global variables

Currently, I am in the process of writing unit tests for code that utilizes a JavaScript library. This particular library sets a global variable if it does not already exist using the following pattern: var GLOBAL_VAR = GLOBAL_VAR || {} While this method ...

"Troubleshooting: Issue with updating page CSS in browser when using npm, node-sass, and concurrent in an

Embarking on a new Angular2 project to enhance my skills, I've made the decision to avoid Yeoman Generator and tools like Grunt or Gulp due to the software still being in development. Instead, I'm utilizing the Node Package Manager to run automat ...

JavaScript powered caller ID for web applications

I am currently working on an innovative project where I aim to automatically detect the phone number of a landline call to a specific device. While research led me to various packages like npm caller-id-node that work with desktop applications using the mo ...