• Register
1 vote
386 views

Problem :

I am very new to Node.js. I want to create a small application which uses the express and mongosse to store some of the users in my based cloud database i.e. mongoDB via mlab.

Please find below MyUser.js (models/MyUser.js)

var dbmongoose = require('mongoose');
module.exports = dbmongoose.model('MyUser', {

   myemail : string ,
   mypwd : string

});

If I try to execute : nodemon myserver.js, Then I face below error :

ReferenceError: string is not defined
    at Object.<anonymous> (D:\Bureau\MEAN\appBackend\models\MyUser.js:5:12)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (D:\Bureau\MEAN\appBackend\server.js:6:12)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:389:7)
[nodemon] app crashed - waiting for file changes before starting...
I am working very hard from past few days to fix above error but I am still unable to fix it.
I am looking for expert help to fix above error.
8 5 2
3,230 points

Please log in or register to answer this question.

1 Answer

1 vote

Solution :

I am expert in Node.js I can certainly help you in fixing above error. The Mongoose expects from you to specify the types using your built-in constructor functions which should always be named with the capital letters, For Example. StringIntegerBoolean, and so on.

Please write the code as shown below to fix your error.

var dbmongoose = require('mongoose');

module.exports = dbmongoose.model('MyUser', {

   myemail : String ,
   mypwd : String

});

 

8 4 1
5,680 points

Related questions

1 vote
1 answer 23 views
23 views
Problem : I tried installing but that didn't work , Its throw this error : node.js:201 throw e; // process.nextTick error, or 'error' event on first tick ^ Error: Cannot find module 'mongoose' at Function._resolveFilename (module.js:334:11) at Function._load (module.js ... Function._load (module.js:310:12) at Module.require (module.js:357:17) Does anyone know what it is and how to solve it? Thanks
asked Mar 29 Sabbir Hossain 14.6k points
0 votes
1 answer 395 views
0 votes
1 answer 7 views
7 views
Problem: I am using node with express + mongoose and trying to use passport.js with restful api. I keep getting this exception after authentication success (I see the callback url on the browser): Passport.initialize() middleware not in use
asked Apr 2 ummesalma 27.3k points
0 votes
1 answer 16 views
16 views
Problem: I faced this error, how I can fix it: Nodemon' is not recognized as an internal or external command, operable program or batch file.
asked Mar 13 Wafa Abu Yousef 6.1k points
0 votes
1 answer 2.5K views
2.5K views
Problem : I am beginner in the node.js .Currently I am trying to install node.js using the below command npm install nodemon --save. But when I try to run a server with below command nodemon server.js. then in my terminal I face below error: &ldquo;Nodemon is not recognized as internal or external command, operable program or batch file&rdquo;
asked Feb 13, 2020 mphil 2.3k points
0 votes
1 answer 6 views
6 views
Problem: I need someone&rsquo;s help to fix it. Mongoerror: e11000 duplicate key error collection:
asked Mar 21 Ifra 25.7k points
0 votes
1 answer 7 views
7 views
Problem: Any help, I will be so thankful: Deprecationwarning: collection.ensureindex is deprecated. use createindexes instead.
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
1 answer 2.1K views
2.1K views
Problem : I am getting following error: Deprecationwarning: collection.ensureindex is deprecated. use createindexes instead. Where is above error coming from? I am not at all using ensureIndex or createIndex in my Nodejs application anywhere. I am using the yarn package manager. ... ', { useNewUrlParser: true }); const myapp = express(); Does anyone ever faced this issue? Any solution on it?
asked Dec 10, 2019 alecxe 7.5k points
0 votes
1 answer 8 views
8 views
Problem: What are my options for dealing with this issue &ldquo;unable to find the wrapper "https" - did you forget to enable it when you configured php&rdquo;?
asked Apr 6 tuhin1 48.9k points
1 vote
1 answer 9 views
9 views
Problem: Is some body here to tell me why I am getting this warning? You configured http(80) on the standard https(443) port!.
asked Mar 26 PkGuy 14k points