Iam using this command : npm run server
I've been looking for a solution to this but don't know why the results still don't work. I've tried installing it globally npm install -g nodemon
but still not restarting automatically only gets posts like this :
i got this not only in file Validations\register.js
[nodemon] files triggering change check: validations\register.js [nodemon] matched rule: ***.* [nodemon] changes after filters (before/after): 1/1 [nodemon] restarting due to changes... [nodemon] Validations\register.js
Package.json
{
"name": "devconnector",
"version": "1.0.0",
"description": "express react",
"main": "server.js",
"scripts": {
"start": "node server.js",
"server": "nodemon server.js --verbose"
},
"author": "Faris Dewantoro",
"license": "MIT",
"dependencies": {
"bcryptjs": "^2.4.3",
"body-parser": "^1.18.3",
"express": "^4.16.4",
"gravatar": "^1.6.0",
"jsonwebtoken": "^8.3.0",
"mongoose": "^5.3.4",
"passport": "^0.4.0",
"passport-jwt": "^4.0.0",
"validator": "^10.8.0"
},
"devDependencies": {
"nodemon": "^1.17.3"
}
}
Server.js
const express = require('express');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const passport = require('passport');
// ROUTER
const users = require('./routes/api/users');
const profile = require('./routes/api/profile');
const posts = require('./routes/api/posts');
const app = express();
app.use(bodyParser.urlencoded({extended:false}));
app.use(bodyParser.json());
// DB Config
const db = require('./config/keys').mongoURI;
// Connect to MongoDB
mongoose
.connect(db,{ useNewUrlParser: true })
.then(()=>{
console.log('MongoDB Connected');
})
.catch((err)=>{
console.log(err);
});
// Passport middleware
app.use(passport.initialize());
// Passport Config
require('./config/passport')(passport);
// User routes
app.use('/api/users',users);
app.use('/api/profile',profile);
app.use('/api/posts',posts);
const port = process.env.PORT || 5000;
app.listen(port,()=>{
console.log(`Server running on port ! ${port}`);
});
how to fix this so that the nodemon can restart the server automatically
Note : Iam using Windows 10 Pro 2018 64x
Update I tried with code like this and the results remained the same :
const express = require('express');
const app = express();
const port = process.env.PORT || 5000;
app.listen(port,()=>{
console.log(`Server running on port ${port}`);
});
[nodemon] 1.17.3 [nodemon] to restart at any time, enter
rs
[nodemon] or send SIGHUP to 10316 to restart [nodemon] watching: . [nodemon] watching extensions: js,mjs,json [nodemon] startingnode server.js
[nodemon] forking [nodemon] child pid: 18172 [nodemon] watching 13 files Server running on port ! 5000
When i changed console.log(
Change testing ${port});
[nodemon] files triggering change check: server.js
[nodemon] matched rule: ***.* [nodemon] changes after filters (before/after): 1/1 [nodemon] restarting due to changes...
[nodemon] Server.js