when I start my JS file, I get the follow error:
Charon:modules Modius$ node testfile.js
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
ReferenceError: define is not defined
at Object.<anonymous> (/Applications/MAMP/htdocs/spacebattles/server/modules/testfile.js:11:1)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Array.0 (module.js:479:10)
at EventEmitter._tickCallback (node.js:192:40)
Charon:modules Modius$
and here the js file
define(['./db_user'], function (db_user) {
var db_user = document.createElement("db_user.js");
var tranfer = {
login: "test" ,
email: "holishitumsonst.com",
password: "123nu"
};
db_user.insert(transfer);
});
thanks for help
I think you may misunderstood the concept of node. Like Florian sayed, node.js is “only” the V8 engine withouth a browser around it. This means you have no document (no DOM at all).
To get started with node.js I recommend you to look into O’Reilly’s Up and running with node.js. The modular system is explained there, too.
In Order to use MongoDB with node you have to use packages like mongoose or mongolian installed through npm. Both are explained in the book I mentioned above.