Stack Exchange
what is "config is not defined"
I'm doing for mariadb connection. but, i faced this error. what is this? i'm node beginner. i want professinal adivce. node.js is errorful as beginner. i waiting correct your advice
var sequelize = new _sequelize2.default(config.database, config.username, config.password, 
config);
                                        ^

ReferenceError: config is not defined
    at Object.<anonymous> (C:/Users/mpkw1/src/models/index.js:9:33)
    at Module._compile (module.js:569:30)
    at loader (C:\Users\mpkw1\AppData\Roaming\nvm\v8.1.2\node_modules\babel-cli\node_modules\babel-register\lib\node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (C:\Users\mpkw1\AppData\Roaming\nvm\v8.1.2\node_modules\babel-cli\node_modules\babel-register\lib\node.js:154:7)       
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:/Users/mpkw1/src/index.js:5:1)
    at Module._compile (module.js:569:30)
    at loader (C:\Users\mpkw1\AppData\Roaming\nvm\v8.1.2\node_modules\babel-cli\node_modules\babel-register\lib\node.js:144:5)

this is User.js in midels folder
module.exports = (sequelize, DataTypes) => {
    return sequelize.define('user', {
        user_id : { ... },
        id : { ... },
        password : { ... },
        nickname : { ... }
    });
};

this is sequelize.js in config folder
{
  "development": {
    "username": "root",
    "password": null,
    "database": "database_development",
    "host": "127.0.0.1",
    "dialect": "mariadb",
    "operatorsAliases": false
  },
  "test": {
    "username": "root",
    "password": null,
    "database": "database_test",
    "host": "127.0.0.1",
    "dialect": "mariadb",
    "operatorsAliases": false
  },
  "production": {
    "username": "root",
    "password": null,
    "database": "database_production",
    "host": "127.0.0.1",
    "dialect": "mariadb",
    "operatorsAliases": false
  }
}

in src/index.js
const Koa = require('koa');
const app = new Koa();

//const sequelize = require('./models');
import { sequelize } from './models';
sequelize.sync().then(() => {
    console.log('✓ DB connection success.');
})
.catch(err => {
    console.error(err);
    console.log('✗ DB connection error. Please make sure DB is running.');
    process.exit();
});

app.listen(4000, () => {
    console.log('server is listening to port 4000');
});

almost module is new version.

did you initialise config?

const config =  require('config');

const config = require(path.join(__dirname, '..', 'config', 'config.json'))['ipse'];
solution is add this line. really smoll thing.... thank you comment! ^.^

It looks like you have not not defined config in your index.js file. Try adding something like this at the top of your index.js file: Either
const config = require('config');

Or, if you are using TypeScript:
import config from 'config';

This will load the configuration file based on the value of NODE_ENV environment variable. If you don’t have this variable set, it will use the default.json file in your config directory.
