nodemon keeps attempting to restart the server after making changes to files, but the updates are not being reflected

I've been using the nodemon package, but I'm experiencing issues with it not restarting the server properly. Instead of showing "server running" after making changes like in tutorials, all it displays is "restarting due to changes". This also results in my work not updating when viewed in a browser.

I've researched numerous related questions on Stack Overflow and tried various solutions like installing dependencies locally as devdependent and changing script tags in the package.json file, but nothing seems to be working.

I've attempted different commands such as nodemon, npm start, nodemon app.js,

nodemon lib/dev-server.js --delay 1
, nodemon -L, and many others, but none have resolved the issue.

================================================================================= edited question:

Currently, I am using VS Code and trying to run JavaScript code with the Express framework. Even a basic hello world code is failing to run with nodemon in my Git Bash terminal. Here are the steps I've followed: node -v and npm -v both work fine on my Bash terminal. I created a simple hello world express app by using npm init and npm install express --save

Here's the link to my testApp GitHub repository: https://github.com/webdevshiv/testApp.git
The main problem lies with nodemon. I installed nodemon with npm install nodemon --save-dev and also tried nodemon install -g. In the script tag,

"scripts": { "start": "node app.js" }
was added. When attempting to run nodemon with nodemon app.js, I encountered the error:
(bash: nodemon: command not found)

However, node app.js is working without any problems. Upon using npx nodemon app.js, the output showed "Example app listening at http://localhost:3000 [nodemon] restarting due to changes..." which indicates that nodemon isn't functioning correctly despite being able to detect changes.

Previously, nodemon was operational under normal circumstances, but now it has completely stopped working...

I've included my system environment variable path for reference:

C:\Program Files\MongoDB\Server\4.2\bin;C:\Program Files\Git\cmd; C:\Program Files\nodejs; C:\Program Files\nodejs\node_modules\npm

For visual aids, here are links to screenshots from my VS Code setup: https://i.sstatic.net/7cslK.jpg https://i.sstatic.net/HaFOf.jpg

Answer №1

If you encounter issues, consider including the directory of your system 32 (such as 'C:\Windows\System32') in the environment variables.

This solution resolved the problem for me.

Answer №2

$npm ls chokidar 

Make sure to execute the command above in the same directory where nodemon is installed. I can confirm that this method was successful for me.

Answer №3

The advice from @Adeel is spot on. This is how I went about testing the solution:

First, clone the demo repository, navigate to the directory, and install the necessary dependencies

$ git clone https://github.com/webdevshiv/testApp.git
$ cd testApp
$ npm install

Next, install nodemon (as recommended by Adeel and the nodemon website [1])

$ npm install -g nodemon

Follow the instructions provided on their website for using nodemon

Simply use nodemon instead of node to run your code...

In this case, you would execute (as per Adeel's suggestion)

$ nodemon app.js

Upon running this command, nodemon should start with output similar to the following:

$ nodemon app.js
[nodemon] 2.0.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node app.js`
Example app listening at http://localhost:3000

If any changes are made in app.js, nodemon will automatically reload the express server.

To enhance the setup further, consider updating the start script in package.json like so:

  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "nodemon app.js"
  },

With this modification, you can simply use $ npm start to initiate nodemon.

[1]

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

How to retrieve a Typescript variable within an ngIf conditional statement in Angular

How can I access a TypeScript variable inside an ngIf statement? TS: public data: string; HTML: <td> <div *ngIf="data === 'BALL' ; else noplay" >{{ play }}</div> <ng-template #noplay> {{ gotohome ...

What is the best way to retrieve routes from a custom REST API using React Native?

Working on developing an app for my company has been an exciting challenge for me. Being new to programming, I decided to take a react-native course and a nodeJs course to enhance my skills. One particular question I have is related to fetching data from m ...

Update the image source through an AJAX call

I've experimented with various methods to update an image src using an AJAX request. The new URL is obtained through the AJAX call, and when inspecting the data in Developer Tools, the 'DATA' variable contains the correct URL. However, the i ...

The image selection triggers the appearance of an icon

In my current project, I am working on implementing an icon that appears when selecting an image. The icon is currently positioned next to the beige image, but I am facing difficulties in making it disappear when no image is selected. Below are some image ...

No results found when attempting to intersect mouse click raycast on point cloud in Three JS (empty array returned)

I've been working on rendering a point cloud and attempting to select a single point, but unfortunately, the method raycaster.intersectObjects(scene.children, true) is returning an empty array. I've tried various methods to calculate the pointer. ...

Having trouble with Raphael's animation callback function?

It seems like I may not be using the callback feature correctly because when I run the code below, the "testCircle" doesn't animate before it disappears. var paper = Raphael(0, 0, 1280,600); var testCircle = paper.circle(300, 300, 50); test ...

Why does this image slider begin with blankness?

For my recent school project, I created an image slider. However, upon starting the page or reloading it, only the arrows and dots are displayed. View screenshot of the issue Below is the code snippet: // JavaScript function to control the slideshow sho ...

Getting a file object with v-file-input in Nuxt.js

For my Nuxt.Js apps, I utilized Vuetify.js as the UI framework. In order to obtain the file object when uploading files, I incorporated the v-file-input component from Vuetify.js and wrote the following code snippet: <template> <div> ...

Having trouble with Angular's ng-tags-input? Are you getting the error message "angular is not defined"? Let

I recently created a new Angular project using the following command: ng new "app-name" Now, I'm attempting to incorporate ngTagsInput for a tag input feature. However, every time I try to build and run my app, I encounter an error in my browser con ...

What is the process for including a designated IP address in the header of Postman, or another comparable testing tool?

I am currently testing the security of my backend protection logic, specifically to see if it is possible for someone to manually change their IP and send a GET request to my website. My website should only be accessible from certain IPs within a specified ...

Encountering difficulties triggering the click event in a JavaScript file

Here is the example of HTML code: <input type="button" id="abc" name="TechSupport_PartsOrder" value="Open Editor" /> This is the jQuery Code: $('#abc').click(function () { alert('x'); }); But when I move this jQuery code to a ...

Customizing Vue: Implementing an automatic addition of attributes to elements when using v-on:click directive

We are currently working with single file Vue components and we're facing a challenge in our mousemove event handler. We want to be able to determine if the target element is clickable. Within our Vue templates, we utilize v-on directives such as: v- ...

Encountering unresponsiveness in Auth0 and Express-openid-connect callback

Running a node express application on port 3002 due to port 3000 being already in use. To handle user logins, Auth0 and the Express-openid-connect package are used. Encountering an issue during login where after attempting to log in, a blank page labeled ...

Loading custom places in ArcGIS from a file or database

Hey there, I was wondering about loading custom places with Arcgis similar to Google maps loading from a .xml file. I noticed that Arcgis uses examples saved in .json format, but when I tried putting the example .json on my local server it wouldn't lo ...

What is the best method for creating an HTML table using a JSON object?

Currently, I am in the process of developing an express app that can render a csv file and convert it into a json format. Within my method, I have this json data stored as a variable and my goal is to display it as a table on an HTML page. How can I effect ...

preventing the ball from landing inside the container (JavaScript)

I developed a straightforward website with the following functionality: Upon entering any text into the prompt and clicking okay, a ball will drop into the 1st box, namely the Past Thoughts box. Below is the code snippet: HTML <h1> Welcome t ...

Error: Unbalanced parentheses detected in the argument list at file path C:UsersgajjaOneDriveDesktopuser_loginviewsupdate.ejs during ejs compilation

When I try to update, instead of showing the form fill field, an error pops up. Can someone assist me with this? <!DOCTYPE html> <html> <head> <title>Form Data</title> </head> <body> <h1>Form Dat ...

Node.js - Are there any modules that function similarly to the request module in Node.js?

Looking to create REST API calls from my Node server and currently considering the request module. Do you have any recommendations for a better module for making REST calls (GET/POST) in production when working with Node.js? Thanks, Ram ...

Web Page Content Scrambling/Character Exchange

I've encountered a perplexing issue that seems to strike randomly, yet I've managed to replicate the problem on three different desktops. Oddly enough, some other desktops never experience this issue and I'm at a loss as to what could be cau ...

Suggestions on how to refactor redundant code in various peer AngularJS controllers for handling $intervals

In my compact single-page application, I have implemented multiple tabs to display operational status information for different applications. Each tab is associated with a controller that creates $interval objects to make AJAX calls to fetch status data fr ...