Mongoose error: TypeError: schema is not a constructor? in Node

problem description

create a student Schame, with mongoose but report an error at run time, the error is in the Schema; of the third line

TypeError: schema is not a constructor

looked at the code did not find a mistake, please help to have a look, thank you!

related codes

var mongoose = require("mongoose"),
    Schema = mongoose.Schema;
const courseInf = new Schema({
    teacher:String,
    courseName:String
});
const student = new Schema({
    name:String,                //
    class:String,                //
    stunum:String,                //
    oldpassword:String,           //
    newpassword:String,           //
    phonenum:String,              //
    course:[courseInf]           //
});

module.exports.stu = mongoose.model("student",student);
Apr.22,2021

try to replace Schema = mongoose.Schema; with const {Schema} = mongoose;


this file should have no problem, feel that the location of the file you located is wrong, it is best to post the error message.
Please search globally to see if there are places where Schema = new mongoose.Schema; , that is, an extra new

has been written.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5a194-45581.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5a194-45581.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?