Meteor, Apollo a Sequelize: Nelze najít modul 'config.json'

hlasů
1

Nedávno přidal novou instalaci meteor podél Apollo a sequelize, vytvořili soubor .sequelizerc, který pracuje podle potřeby, ale když jsem běžet meteor se nezdaří s: Chyba: Nelze najít modul ‚/lib/database/mysql/models/..config.json '

Struktura aplikace:

/.meteor
/client
/lib
    /database
        /mysql
            /migrations
            /models
                index.js
            /seeders
            config.json
/node_modules
    /.bin
        .sequelizerc
/server

.sequelizerc file

var path = require('path');

module.exports = {
    'config': path.resolve('../../lib/database/mysql', 'config.json'),
    'migrations-path': path.resolve('../../lib/database/mysql', 'migrations'),
    'models-path': path.resolve('../../lib/database/mysql', 'models'),
    'seeders-path': path.resolve('../../lib/database/mysql', 'seeders'),
}

/lib/database/models/index.js file

var fs        = require('fs');
var path      = require('path');
var Sequelize = require('sequelize');
var basename  = path.basename(module.filename);
var env       = process.env.NODE_ENV || 'development';
var config    = require(__dirname + '/..\config.json')[env];
var db        = {};

if (config.use_env_variable) {
    var sequelize = new Sequelize(process.env[config.use_env_variable]);
} else {
    var sequelize = new Sequelize(config.database, config.username, config.password, config);
}

fs
    .readdirSync(__dirname)
    .filter(function(file) {
        return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js');
    })
    .forEach(function(file) {
        var model = sequelize['import'](path.join(__dirname, file));
        db[model.name] = model;
    });

Object.keys(db).forEach(function(modelName) {
    if (db[modelName].associate) {
        db[modelName].associate(db);
    }
});

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

module.exports = db;

package.json

{
    name: meteor-apollo-sequelize,
    private: true,
    scripts: {
        start: meteor run
    },
    dependencies: {
        apollo-client: ^0.3.12,
        apollo-server: ^0.1.1,
        express: ^4.14.0,
        graphql: ^0.6.2,
        graphql-tools: ^0.6.4,
        meteor-node-stubs: ^0.2.3,
        mysql: ^2.11.1,
        sequelize: ^3.24.0,
        sequelize-cli: ^2.4.0
    }
}
Položena 17/08/2016 v 09:40
zdroj uživatelem
V jiných jazycích...                            


1 odpovědí

hlasů
2

Opravu zpětného lomítka / lomítko - změňte tento řádek:

var config = require(__dirname + '/..\config.json')[env];

na

var config = require(__dirname + '/../config.json')[env];
Odpovězeno 18/08/2016 v 02:00
zdroj uživatelem

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more