I am using MEAN stack, I have a file project.js in models directory and it contains schema for my nosql. I am trying to use that module in my controller file Project.js but I am getting error on this:
const Pro = require('../models/project')
When I comment this line code works but again its not mapped and not saving the data in my MongoDB.
My project.js is below
const mongoose = require('mongoose')
var projSchema = new.mongoose.Schema(
{
name:
{
type: String,
required = true
},
dueDate:
{
type:Date
},
course:
{
type: String,
required = true
}
})
module.exports= mongoose.model('Pro',projSchema);
Error:
internal/modules/cjs/loader.js:888
throw err;
^
Error: Cannot find module 'C:Program Files
odejsExpressTracker2models'
one typo is here
or
maybe your problem in importing and exporting model
or