2

I am trying to follow this tutorial, I cannot run the node server because of this error :

TypeError: Cannot read property 'name' of undefined at makeSkinClass

Here is my path :

echo $PATH /usr/local/mysql/bin:/mongodb/bin:Users/Empon/npm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin

I figured out that -g never works in my Terminal, so I tried to add the paths to the PATH permanently, I added mongodb to both bashrc, and bash_profile.

Then I did npm install -g mongodb, I had this :

mongodb-core@1.2.32 requires a peer of kerberos@~0.0 but none was installed.

So I added npm install --save kerberos mongodb and the result was :

npm WARN skippingAction Module is inside a symlinked module: not running remove bson@0.4.21 node_modules/mongodb/node_modules/bson npm WARN skippingAction Module is inside a symlinked module: not running remove core-util-is@1.0.2

Now, in my Node project, I do : node bin/www to start the server (I tried node app.js, with "app.js" in the config file, but it did not work, so I let ./bin/www), and the url is : http://localhost:3000/api/videos.

Would you know what is wrong?


EDIT: I got it working, with these manipulations : installing an older version of mongodb and changing a line in a config file :

Does run mongoskin only with mongodb version 1.4 and older?

Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' } js-bson: Failed to load c++ bson extension, using pure JS version

I am almost there, the url to the port works fine (http://localhost:3000/), but not the one for mongodb (http://localhost:3000/api/videos), the error is :

Error: Not Found at /Applications/MAMP/htdocs/workspace/Vidzy/app.js:32:13 at Layer.handle [as handle_request] (/Applications/MAMP/htdocs/workspace/Vidzy/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/Applications/MAMP/htdocs/workspace/Vidzy/node_modules/express/lib/router/index.js:312:13)

And my code is :

//in routes/video.js
var express = require('express');
var router = express.Router();
var monk = require('monk');
var db = monk('localhost:27017/vidzy');

router.get('/', function(req, res){
    var collection = db.get('videos');
    collection.find({}, function(err, videos){
       if (err) throw err;
       res.json(videos);
    });
});
module.exports = router;


//in app.js
// catch 404 and forward to error handler
app.use(function(req, res, next) {
  var err = new Error('Not Found');
  err.status = 404;
  next(err);
});

The Terminal is connected to mongoDB :

I NETWORK [initandlisten] waiting for connections on port 27017

Would someone know why I get a 404, and how to debug this?

Community
  • 1
  • 1
Paul
  • 6,108
  • 14
  • 72
  • 128
  • 1
    This seems like you are missing a required module. Perhaps re-run `npm install mongoskin --save` in the app directory to be sure. Don't forget to use `--save` or `--save-dev` when you are installing dependencies. – Pete Garafano Jan 21 '16 at 22:17
  • 1
    Try to follow this solution https://github.com/kissjs/node-mongoskin/issues/153#issuecomment-85740639 – Maxali Jan 21 '16 at 22:32
  • @PeteGarafano thanks, I found a solution with the 2 urls I posted, but my page does not work yet, could you have a look at my edit? – Paul Jan 22 '16 at 00:14
  • @Maxali thanks, same as for Pete, I found a solution with the 2 urls I posted, but my page does not work yet, could you have a look at my edit? – Paul Jan 22 '16 at 00:14
  • I think this `http://localhost:3000/api/videos` is *MongoDB* REST interface. If so, its not running the same port `3000` as `express`. Try port `28017` and restart `mongod` with `--rest` option. – Maxali Jan 22 '16 at 01:36
  • @Maxali no I made a mistake, I wrote "app" instead of "api" in my route... now it is working fine. Thank you very much for your help anyway – Paul Jan 22 '16 at 01:54

1 Answers1

0

I solved my problem : the version of mongodb was incorrect, and so was the version of mongoskin. I don't know much about why the error occured, but setting the project with mongodb 1.4 and mongoskin 1.3 works fine.

npm install mongoskin@1.3.20 --save

and

$ npm install mongodb@~1.4 --save

source: Does run mongoskin only with mongodb version 1.4 and older?


In case something is wrong with the debug file, here is the change to make :

replace : bson = require('../build/Release/bson');

with : bson = require('../browser_build/bson');

in :

npm module mongodb ..node_modules\mongodb\node_modules\bson\ext\index.js

source : Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' } js-bson: Failed to load c++ bson extension, using pure JS version

Community
  • 1
  • 1
Paul
  • 6,108
  • 14
  • 72
  • 128