sequelize-docs-Zh-CN
sequelize-docs-Zh-CN copied to clipboard
_loadDialectModule require 一个变量在某些情况下加载不到
_loadDialectModule(moduleName) {
try {
if (this.sequelize.config.dialectModulePath) {
return require(this.sequelize.config.dialectModulePath);
}
if (this.sequelize.config.dialectModule) {
return this.sequelize.config.dialectModule;
}
return require("sqlite3");
} catch (err) {
if (err.code === "MODULE_NOT_FOUND") {
if (this.sequelize.config.dialectModulePath) {
throw new Error(Unable to find dialect at ${this.sequelize.config.dialectModulePath}
);
}
throw new Error(Please install ${moduleName} package manually
);
}
throw err;
}
}
return require("sqlite3"); 可以正常执行
return require(moduleName); 就会throw new Error(Please install ${moduleName} package manually
)