Parth Sharma
Parth Sharma

Reputation: 9

unable to run Index.js with nodemon . It is showing "clean exit - waiting for changes before restart"

I am unable to use npm start as it is giving clean exit - waiting for changes before restart. What should I do to remove the error The output should be "port is running at 5000"

 (base) parthsharma@Parths-MacBook-Air server % npm start 

> [email protected] start /Users/parthsharma/Desktop/Recollection_project/server
> nodemon index.js

[nodemon] 2.0.7

[nodemon] to restart at any time, enter `rs`

[nodemon] watching path(s): *.*

[nodemon] watching extensions: js,mjs,json

[nodemon] starting `node index.js`

[nodemon] clean exit - waiting for changes before restart

^C%   
                                                                         
(base) parthsharma@Parths-MacBook-Air server % nodemon index.js

zsh: command not found: nodemon




^C%                                                                            
(base) parthsharma@Parths-MacBook-Air server % 
(base) parthsharma@Parths-MacBook-Air server %  nodemon -w ./ 
zsh: command not found: nodemon
(base) parthsharma@Parths-MacBook-Air server % 

Index.js:

import express from 'express';
import bodyParser from 'body-parser';
import mongoose from 'mongoose';
import cors from 'cors';

const app = express();

app.use(express.json({ limit: "30 mb", extended: true }));
app.use(express.urlencoded({ limit: "30 mb", extended: true }));
app.use(cors());

const CONNECTION_URL = 'mongodb+srv://parthsharma:[email protected]/myFirstDatabase?retryWrites=true&w=majority';
const PORT = process.env.PORT || 5000;

mongoose.connect(CONNECTION_URL, { useNewUrlParser: true, useUnifiedTopology: true })
    .then(() => app.listen(PORT, () => console.log('Server running on port: ${PORT}')))
    .catch((error) => console.log(error.message));

mongoose.set('useFindAndModify', false);


Upvotes: 0

Views: 904

Answers (3)

YT GAMEWORKS
YT GAMEWORKS

Reputation: 93

Do you have Nodemon as a dependency of your project or installed globally?

If globally, then you've installed it wrong! It doesn't recognize nodemon! try this:

npm uninstall nodemon
npm install -g nodemon 

If locally then, try execute it with node once, see if it doesn't do anything too!

Edit: Looks like the second time you tried to execute it like so:

nodemon index.js

That won't work! nodemon is always supposed to be executed as an npm script!

Upvotes: 0

OBrien Evance
OBrien Evance

Reputation: 1065

Have you tried installing nodemon as a development manager

npm i nodemon --save-dev

Upvotes: 0

Rukshan Jayasekara
Rukshan Jayasekara

Reputation: 1985

  1. Delete the nodemon package from package.json. (Simply remove the line)
  2. Then run sudo npm install -g --force nodemon

For more info refer to this.

Upvotes: 1

Related Questions