Reputation: 111
I am trying to write a simple TODO MEAN application, with instructions from scotch.io.
server.js has the following nodejs related code.
server.js
// set up ========================
var express = require('express');
var app = express(); // create our app w/ express
var mongoose = require('mongoose'); // mongoose for mongodb
var morgan = require('morgan'); // log requests to the console (express4)
var bodyParser = require('body-parser'); // pull information from HTML POST (express4)
var methodOverride = require('method-override'); // simulate DELETE and PUT (express4)
// configuration =================
mongoose.connect('mongodb://node:[email protected]:27017/uwO3mypu'); // connect to mongoDB database on modulus.io
app.use(express.static(__dirname + '/public')); // set the static files location /public/img will be /img for users
app.use(morgan('dev')); // log every request to the console
app.use(bodyParser.urlencoded({'extended':'true'})); // parse application/x-www-form-urlencoded
app.use(bodyParser.json()); // parse application/json
app.use(bodyParser.json({ type: 'application/vnd.api+json' })); // parse application/vnd.api+json as json
app.use(methodOverride());
// listen (start app with node server.js) ======================================
app.listen(8080);
console.log("App listening on port 8080");
On the Ubuntu terminal, On typing "node server.js" to run the server.
I am getting no response.
satyajit@Sunny:~/Documents/git repositories/mean-todo-app$ node server.js
satyajit@Sunny:~/Documents/git repositories/mean-todo-app$ node server.js
satyajit@Sunny:~/Documents/git repositories/mean-todo-app$ ls -l
total 16
drwxrwxr-x 7 satyajit satyajit 4096 Jun 28 11:03 node_modules
-rw-rw-rw- 1 satyajit satyajit 357 Jun 28 09:41 package.json
drwxrwxr-x 2 satyajit satyajit 4096 Jun 27 20:37 public
-rw-rw-rw- 1 satyajit satyajit 1455 Jun 28 09:41 server.js
Can anybody tell where am I going wrong or am I missing anything that needs to be done???
Upvotes: 3
Views: 1133
Reputation: 7002
as Stated by Satyajit, ubuntu uses nodejs server.js
.
I'll just say that people sometimes get all sort of problems because of it, since a lot of modules you install will assume the executable for node.js is node
(not to talk about tutorials on the internet).
in order to get better compatibility, I suggest you run this command:
sudo ln -s /usr/bin/nodejs /usr/bin/node
This will create a symbolic link for "node". Then, you can use
node server.js
Upvotes: 3