When I typed "nodemon server.js" command in the terminal, it returns the error "require('update-notifier')({ pkg }).notify();". The version of nodemon installed is [email protected]
Below are the javascript and html used.
var express = require('express');
var app = express();
var port = 8888;
app.get('/', function(req, res, next) {
res.sendFile(__dirname + '/index.html');
});
app.listen(port, '0.0.0.0', function() {
console.log('Server running at port ' + port);
});
<!DOCTYPE html>
<html>
<head>
<title>My NodeJS Website</title>
</head>
<body>
<p>Hello World!</p>
</body>
</html>
Use npx to solve the error "'nodemon' is not recognized as an internal or external command, operable program or batch file", e.g. npx nodemon server. js or install the package globally by running npm install -g nodemon and make sure your PATH environment variable is set up correctly.
Running non-Node code While Nodemon is running, we can manually restart our application. So instead of stopping and restarting Nodemon, we can just type rs and press enter, and Nodemon will restart the server or the running process for us.
That error is telling that your node version does not support object literal property value shorthand, which was introduced in node 4, which is the required version for nodemon.
You should update your node version, since it's not a nodemon issue.
To provide further proof, executing nodemon on a docker container with node 0.12.15 installed trigger that exact same error.
Node 0.12.15
And it doesn't happen on node >= 4
I recommend updating your node version to 8.11.1 which is the current LTS
If you can't upgrade your node version (which you should), you can downgrade nodemon to version 1.11.0 which runs on node >= 0.8.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With