Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4531220
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T13:53:01+00:00 2026-05-21T13:53:01+00:00

Hey all, I’m very new to mongodb, mongoose and node.js. I would like to

  • 0

Hey all,
I’m very new to mongodb, mongoose and node.js. I would like to create a little demo to see how mongoose works. After installing (and testing the correctes of) node.js I downloaded mongoose and tried the following code (also provided on the mongoose website):

require.paths.unshift('vendor/mongoose');
var mongoose = require('mongoose').Mongoose;

mongoose.model('User', {

properties: ['first', 'last', 'age', 'updated_at'],

cast: {
  age: Number,
  'nested.path': String
},

indexes: ['first'],

setters: {
    first: function(v){
        return this.v.capitalize();
    }
},

getters: {
    full_name: function(){ 
        return this.first + ' ' + this.last 
    }
},

methods: {
    save: function(fn){
        this.updated_at = new Date();
        this.__super__(fn);
    }
},

static: {
    findOldPeople: function(){
        return this.find({age: { '$gt': 70 }});
    }
}

});

var db = mongoose.connect('mongodb://localhost/db');

var User = db.model('User');

var u = new User();
u.name = 'John';
u.save(function(){
sys.puts('Saved!');
});

User.find({ name: 'john' }).all(function(array){

});

The problem is that when I run node myfile.js I got the following error:

node.js:181
    throw e; // process.nextTick error, or 'error' event on first tick
    ^
Error: Cannot find module 'mongoose'
at Function._resolveFilename (module.js:320:11)
at Function._load (module.js:266:25)
at require (module.js:364:19)
at Object.<anonymous> (/my/path/to/mongoose+node test/myfile.js:2:16)
at Module._compile (module.js:420:26)
at Object..js (module.js:426:10)
at Module.load (module.js:336:31)
at Function._load (module.js:297:12)
at Array.<anonymous> (module.js:439:10)
at EventEmitter._tickCallback (node.js:173:26)

Now, I have to say again that I’m really new to this, so my folder called “mongoose+node test” has inside only the mongoose folder which contains a bunch of JavaScript files, and of course myfile.js. Am I maybe missing something?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T13:53:01+00:00Added an answer on May 21, 2026 at 1:53 pm

    In the new version, you don’t need to use .Mongoose .

    Just replace the following :

    var mongoose = require('mongoose').Mongoose;

    with:

    var mongoose = require('mongoose')

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all. Okay here is the situation. I would like to be able to
Hey all i have created dynamic buttons at runtime and i would like to
Hey all i am in need of a little help with figuring out how
Hey all, I'm having a little trouble packing a numpy.float32 using the struct.pack function.
Hey all. I have the following code: http://jsfiddle.net/g7Cgg/ As you can see, there are
Hey all i am trying to find some code that would allow me to
Hey all, I basically output content into a div like this using jquery: var
Hey all. I'm trying to see about handling events in a console application. I
Hey all, I was working on a recursive generator to create the fixed integer
Hey all I have a large html string like <a style=background: rgb(100, 101, 43)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.