5

I use express and sequelize for the creation of a web server. I use the CLI of sequelize for the creation of models and migrations.

I would like to change the config.json to config.js in order to be able to use environment variables.

I followed the documentation and created the `.sequelizerc' file as follows =>

const path = require('path');

module.exports = {
  'config': path.resolve('config', 'config.js'),
  'models-path': path.resolve('models'),
  'seeders-path': path.resolve('seeders'),
  'migrations-path': path.resolve('migrations')
}

This works as it should for the CLI sequelize, I can create models or start migrations but I can't start the server because it looks for the file config.json.

So my question is how to make sure that when the server starts, it is able to read config.js.

When i run node bin/www i receive

Error: Cannot find module '/nodeTest/nodejs-relationships/models/../config/config.json'
2
  • How are you call config in your server app? Commented Dec 3, 2018 at 7:38
  • No, since everything is preconfigured with sequelize, I have no idea how to proceed Commented Dec 3, 2018 at 15:01

1 Answer 1

4

The problem was actually my index.js file located in the /models directory, in reality, it tries to require config.json by default, just replace the .json by an .js

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.