Question

I am trying to implement the MEAN stack using the BitNami version. I ran into some errors with the mean-stack-todo demo app - so I decided to build it from scratch(ish) by running express xxx in the terminal, and running npm install. Then I used bower (with the .bowerrc file) to install angular, angular-bootstrap, and jquery into the /public/javascripts/vendor folder. I then went about creating all the files - and making necessary changes to the code. I got to the point where I could go to localhost:3000 and see the page - but there were errors in the console. One of them had to do with index.js (which I had forgotten to change to the version I wanted - it wasn't finding a .json file that was supposed to be in the root directory of the site, because my index.js file was wrong). After making the necessary changes - I can no longer see the page, and my browser hangs on localhost:3000 - it never loads. Here is my index.js file, the problem has to be here (at least partially) because the problem started happening right after I changed it.

routes/index.js

/*
 * GET home page.
 */

exports.index = function(Member) {
  return function(req, res) {
    Member.find({}, function(error, members) {
      res.render('index', {
        title: 'Express',
        members : members
      });
    });
  };
};

exports.addMember = function(Member) {
  return function(req, res) {
    var member = new Member(req.body);
    member.save(function(error, member) {
      if (error || !member) {
        res.json({ error : error });
      } else {
        res.json({ member : member });
      }
    });
  };
};

exports.get = function(Member) {
  return function(req, res) {
    Member.find({}, function(error, members) {
      res.json({ members : members });
    });
  }
};

exports.update = function(Member) {
  return function(req, res) {
    Member.findOne({ _id : req.params.id }, function(error, member) {
      if (error || !member) {
        res.json({ error : error });
      } else {
        member.done = req.body.done;
        member.save(function(error, member) {
          if (error || !member) {
            res.json({ error : error });
          } else {
            res.json({ member : member });
          }
        });
      }
    });
  }
};

Here is another possibly relevant tidbit - when I run node app, I see:

connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
connect.limit() will be removed in connect 3.0

Let me know if you see anything - or need to see any other files. The last error I was getting was that it couldnt find localhost:3000/members.json (but the page was being displayed). Thanks in advance!

Was it helpful?

Solution

I ended up reinstalling the mean-stack-todo app and fixing the error. It was something to do with favicon.ico - and I had to change an app.use(express.favicon()); to app.use(express.favicon(__dirname + '/public/favicon.ico'));. I also had to copy favicon.ico into the public folder.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top