-
-
Notifications
You must be signed in to change notification settings - Fork 248
Open
Labels
questionFurther information is requestedFurther information is requested
Description
I have a nextron with sequelize project, when I run npm run dev
, it get cannot find module of sequelize config error.
A JavaScript error occurred in the main process
Uncaught Exception:
Error: Cannot find module '/Users/john/Desktop/Test/electron/nextron/nextron-demo-03-for-sequelize/app/../config/config.json'
at webpackEmptyContext (/Users/john/Desktop/Test/electron/nextron/nextron-demo-03-for-sequelize/app/background.js:29:10)
at ./models/index.js (/Users/john/Desktop/Test/electron/nextron/nextron-demo-03-for-sequelize/app/background.js:234:101)
at __webpack_require__ (/Users/john/Desktop/Test/electron/nextron/nextron-demo-03-for-sequelize/app/background.js:94223:42)
at ./main/ipc/ipcMainHandlers.ts (/Users/john/Desktop/Test/electron/nextron/nextron-demo-03-for-sequelize/app/background.js:187:65)
at __webpack_require__ (/Users/john/Desktop/Test/electron/nextron/nextron-demo-03-for-sequelize/app/background.js:94223:42)
at /Users/john/Desktop/Test/electron/nextron/nextron-demo-03-for-sequelize/app/background.js:94311:78
at /Users/john/Desktop/Test/electron/nextron/nextron-demo-03-for-sequelize/app/background.js:94342:3
at Object.<anonymous> (/Users/john/Desktop/Test/electron/nextron/nextron-demo-03-for-sequelize/app/background.js:94345:12)
at Module._compile (node:internal/modules/cjs/loader:1120:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1175:10)
there is the nextron with sequelize demo:
https://codesandbox.io/s/slrgv7
the key information:
models/index.js
'use strict';
const fs = require('fs');
const path = require('path');
const Sequelize = require('sequelize');
const process = require('process');
const basename = path.basename(__filename);
const env = process.env.NODE_ENV || 'development';
const config = require(__dirname + '/../config/config.json')[env];
const db = {};
let sequelize;
if (config.use_env_variable) {
sequelize = new Sequelize(process.env[config.use_env_variable], config);
} else {
sequelize = new Sequelize(config.database, config.username, config.password, config);
}
fs
.readdirSync(__dirname)
.filter(file => {
return (
file.indexOf('.') !== 0 &&
file !== basename &&
file.slice(-3) === '.js' &&
file.indexOf('.test.js') === -1
);
})
.forEach(file => {
const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes);
db[model.name] = model;
});
Object.keys(db).forEach(modelName => {
if (db[modelName].associate) {
db[modelName].associate(db);
}
});
db.sequelize = sequelize;
db.Sequelize = Sequelize;
module.exports = db;
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested