这是什么意思?
我使用NodeJs创建了一个简单的Web应用程序并将其部署到Heroku。构建成功,但是当我运行该应用程序时,会抛出此错误。在localhost中效果很好,
internal/modules/cjs/loader.js:638
2019-11-02T19:50:40.185373+00:00 app[web.1]: throw err;
2019-11-02T19:50:40.185375+00:00 app[web.1]: ^
2019-11-02T19:50:40.185377+00:00 app[web.1]:
2019-11-02T19:50:40.185379+00:00 app[web.1]: Error: Cannot find module './options/SchemaTypeOptions'
2019-11-02T19:50:40.185381+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
2019-11-02T19:50:40.185382+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:562:25)
2019-11-02T19:50:40.185384+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:692:17)
2019-11-02T19:50:40.185385+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:25:18)
2019-11-02T19:50:40.185387+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/mongoose/lib/schematype.js:8:27)
2019-11-02T19:50:40.185388+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:778:30)
2019-11-02T19:50:40.185392+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
2019-11-02T19:50:40.185393+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:653:32)
2019-11-02T19:50:40.185395+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
2019-11-02T19:50:40.185396+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:585:3)
我重新安装了node_modules文件夹,但是什么也没有。 你能帮我吗?预先谢谢你!
更新
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const userSchema = new Schema({
name:{
type:String,
required:true
},
password: {
type:String,
required:true
}
});
module.exports = mongoose.model('User', userSchema);
这是我使用架构对象的模型
const express = require('express');
const helmet = require('helmet');
const path = require('path');
const compression = require('compression');
const bodyParser = require('body-parser');
const app = express();
const mongoose = require('mongoose');
const flash = require('connect-flash');
const User = require('./models/user');
const session = require('express-session');
const MongoDBStore = require('connect-mongodb-session')(session);
const bcrypt = require('bcryptjs');
app.use(flash());
app.use(helmet());
app.use(compression());
app.set('view engine', 'ejs');
app.set('views', 'views');
const MONGODB_URI = `mongodb+srv://*******-xo7un.mongodb.net/247SharedKitchen`;
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'public')));
const store = new MongoDBStore({
uri: MONGODB_URI,
collection: 'sessions'
});
app.use(
session({
secret: 'my secret',
resave: false,
saveUninitialized: false,
store: store
})
);
app.post('/uploadLogin', (req,res,next) => {
const password = req.body.password;
User.findOne({name:'users'})
.then(r => {
return bcrypt.compare(password, r.password)
.then(doMatch => {
console.log(doMatch);
if(doMatch) {
req.session.isLoggedIn = true;
req.session.user = r;
return req.session.save(err => {
console.log(err);
req.flash('success', 'You successfully logged in');
res.redirect('/appointments');
})
} else {
console.log('intra aici');
req.flash('error', 'Please provide the right credentials');
res.redirect('/');
}
})
})
})
app.use('/404', (req,res,next) => {
res.render('404', {
pageTitle:'24/7 SHARED KITCHEN | 404',
path:'/404',
});
})
app.use('/stationone', (req,res,next) => {
res.render('stationone', {
pageTitle:'24/7 SHARED KITCHEN | APPOINTMENTS HOME',
path:'/stationone',
});
})
app.use('/stationtwo', (req,res,next) => {
res.render('stationtwo', {
pageTitle:'24/7 SHARED KITCHEN | APPOINTMENTS HOME',
path:'/stationtwo',
});
})
app.use('/stationthree', (req,res,next) => {
res.render('stationthree', {
pageTitle:'24/7 SHARED KITCHEN | APPOINTMENTS HOME',
path:'/stationthree',
});
})
app.use('/ovena', (req,res,next) => {
res.render('ovena', {
pageTitle:'24/7 SHARED KITCHEN | APPOINTMENTS HOME',
path:'/ovena',
});
})
app.use('/ovenb', (req,res,next) => {
res.render('ovenb', {
pageTitle:'24/7 SHARED KITCHEN | APPOINTMENTS HOME',
path:'/ovenb',
});
})
app.use('/appointments', (req,res,next) => {
let message = req.flash('error');
console.log(message);
if(message.length > 0) {
message = message[0];
}
else {
message = null;
}
let message2 = req.flash('success');
console.log(message2);
if(message2.length > 0) {
message2 = message2[0];
}
else {
message2 = null;
}
res.render('appointments', {
pageTitle:'24/7 SHARED KITCHEN | APPOINTMENTS HOME',
path:'/appointments',
errorMessage: message,
succesMessage:message2
});
})
app.use('/', (req,res,next)=> {
let message = req.flash('error');
console.log(message);
if(message.length > 0) {
message = message[0];
}
else {
message = null;
}
let message2 = req.flash('success');
console.log(message2);
if(message2.length > 0) {
message2 = message2[0];
}
else {
message2 = null;
}
res.render('index', {
pageTitle:'24/7 SHARED KITCHEN | APPOINTMENTS HOME',
path:'/',
errorMessage: message,
succesMessage:message2
});
})
mongoose.connect(MONGODB_URI)
.then(result => {
app.listen(process.env.PORT || 80);
})
这是主要应用