类型错误:connectToMongo不是函数
- 我的代码(Index.js)*
const connectToMongo = require('./db')
connectToMongo();
- 我的代码(db.js)*
const mongoose = require('mongoose');
const mongoURI = "mongodb://localhost:27017"
const connectToMongo = ()=> {
mongoose.connect(mongoURI,()=>{
console.log("Connected to mongo successfully")
})
}
module.export = connectToMongo;
任何人都可以帮助?
2条答案
按热度按时间pgvzfuti1#
我觉得这条线
应该是
evrscar22#
你需要改变
到
参见:https://www.freecodecamp.org/news/module-exports-how-to-export-in-node-js-and-javascript/