TypeError:在节点js中使用sequalize时require(...)不是函数

时间:2020-10-10 13:27:45

标签: mysql node.js reactjs express sequelize.js

我是Web开发人员的初学者,并尝试使用Mysql Express React Node js创建Full Stack项目。 在将Sequalize与节点js一起使用时面临此TypeError问题。 我是新来的,我不明白这个问题。有人可以向我解释一下,并帮助我找到解决方案吗? (PS:如果您需要其他文件,请告诉我)

服务器js

library(tidyverse)
updins <- updins %>% mutate(weight = ifelse(weight>200, weight/1000, weight))

索引js


$("button").click(function(){
    $("button").removeClass("btn-n-active"); // Remove other active class
    $(this).addClass("btn-n-active"); // Add active class to the clicked button
});


const myFunction = () => {
    var selectedButtonText = $("button").hasClass("btn-n-active").html();
    console.log("Selected answer: " + selectedButtonText);
}

设备js

const express = require("express");
const bodyParser = require("body-parser");
const cors = require("cors");

const app = express();

var corsOptions = {
  origin: "http://localhost:8081"
};

app.use(cors(corsOptions));

// parse requests of content-type - application/json
app.use(bodyParser.json());

// parse requests of content-type - application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true }));

const db = require("./models");

db.sequelize.sync({ force: true }).then(() => {
  console.log("Drop and re-sync db.");
});

// simple route
app.get("/", (req, res) => {
  res.json({ message: "Welcome." });
});


require("./src/routes/routes")(app);
// set port, listen for requests
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}.`);
});

错误

const dbConfig = require("../config/db.config.js");

const Sequelize = require("sequelize");
const sequelize = new Sequelize(dbConfig.DB, dbConfig.USER, dbConfig.PASSWORD, {
  host: dbConfig.HOST,
  dialect: dbConfig.dialect,
  operatorsAliases: false,

  pool: {
    max: dbConfig.pool.max,
    min: dbConfig.pool.min,
    acquire: dbConfig.pool.acquire,
    idle: dbConfig.pool.idle
  }
});

const db = {};

db.Sequelize = Sequelize;
db.sequelize = sequelize;

db.devices = require("./devices.js")(sequelize, Sequelize);

module.exports = db;

0 个答案:

没有答案