错误471 - 找不到模块!
这是我要写的模型.T 有数据已经在mysql中。从sequilize开始连接。我删除了所有节点模块并再次尝试,没有任何工作。请提出建议。
module.exports = function(sequelize,dataTypes){
var calender = sequelize.define("calender",{
listing_id:DATATYPE.INTEGER,
listdate:DATATYPE.DATE,
available:DATATYPE.TEXT,
price:DATATYPE.TEXT
});
return calender;
};
这是代码
现在这是错误
module.js:471 扔错了; ^
错误:找不到模块' E:\ mindsumo \ dataairbnb \ models / .. configconfig.json'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (E:\mindsumo\dataairbnb\models\index.js:8:17)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (E:\mindsumo\dataairbnb\server.js:10:11)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:390:7)
at startup (bootstrap_node.js:150:9)
at bootstrap_node.js:505:3
制作模型时出错
node_modules/.bin/sequelize model:generate --name calender1 --attributes
listing_id:int, listdate:date, available:text, price:text
node_modules/.bin/sequelize model:generate --name calender1 --attributes listing_id:int, lis
tdate:date, available:text, price:text
Sequelize CLI [Node: 6.10.3, CLI: 3.0.0, ORM: 3.30.4]
E:\mindsumo\studyairbnb\node_modules\sequelize-cli\node_modules\yargs\yargs.js:1079
else throw err
^
TypeError: Cannot read property 'toUpperCase' of undefined
at eval (lodash.templateSources[0]:18:32)
at Array.forEach (native)
at eval (lodash.templateSources[0]:14:26)
at Object.render (E:\mindsumo\studyairbnb\node_modules\sequelize-
cli\lib\helpers\template-helper.js:26:54)
at Object.generateFileContent
(E:\mindsumo\studyairbnb\node_modules\sequelize-cli\lib\helpers\model-
helper.js:31:37)
at Object.generateFile (E:\mindsumo\studyairbnb\node_modules\sequelize-
cli\lib\helpers\model-helper.js:41:49)
at Object.exports.handler (E:\mindsumo\studyairbnb\node_modules\sequelize-cli\lib\commands\model_generate.js:32:27)
at Object.self.runCommand (E:\mindsumo\studyairbnb\node_modules\sequelize-cli\node_modules\yargs\lib\command.js:233:22)
at Object.Yargs.self._parseArgs (E:\mindsumo\studyairbnb\node_modules\sequelize-cli\node_modules\yargs\yargs.js:990:30)
at Object.get [as argv] (E:\mindsumo\studyairbnb\node_modules\sequelize-cli\node_modules\yargs\yargs.js:927:19)
at Object.<anonymous> (E:\mindsumo\studyairbnb\node_modules\sequelize-cli\lib\sequelize:84:15)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
E:\mindsumo\studyairbnb\node_modules\sequelize-
cli\node_modules\yargs\yargs.js:1079
else throw err
^
答案 0 :(得分:1)
如果你使用Express框架,这个例子可以帮到你很多:
https://github.com/sequelize/express-example/tree/master/models
我一开始也遇到了Sequelize的问题。
特别检查:
models/index.js
models/user.js
routes/index.js