카테고리 없음

[에러해결 / Node.js] (Sequelize) ERROR: Error reading "config\config.json". Error: Error: Cannot find module

보리시스템 2023. 1. 17.

남의 팀 플젝 코드 뜯어보기를 하기 위해 sequealize db:create를 하려는데 아래와 같은 에러가 발생했다.

 

터미널창 에러메시지

Sequelize CLI [Node: 18.12.1, CLI: 6.5.2, ORM: 6.28.0]


ERROR: Error reading "config\config.json". Error: Error: Cannot find module 'C:\Users\user\Desktop\bootcamp_nodejs\99_teamstudy\wonbin\src\config\config.json'
Require stack:
- C:\Users\user\Desktop\bootcamp_nodejs\99_teamstudy\wonbin\node_modules\sequelize-cli\lib\helpers\import-helper.js
- C:\Users\user\Desktop\bootcamp_nodejs\99_teamstudy\wonbin\node_modules\sequelize-cli\lib\helpers\config-helper.js
- C:\Users\user\Desktop\bootcamp_nodejs\99_teamstudy\wonbin\node_modules\sequelize-cli\lib\helpers\index.js
- C:\Users\user\Desktop\bootcamp_nodejs\99_teamstudy\wonbin\node_modules\sequelize-cli\lib\commands\init.js
- C:\Users\user\Desktop\bootcamp_nodejs\99_teamstudy\wonbin\node_modules\sequelize-cli\lib\sequelize
sequelize db:create

Create database specified by configuration

Options:
  --version          Show version number                                                                                                                [boolean]  --help             Show help                                                                                                                          [boolean]  --env              The environment to run the command in                                                                      [string] [default: "development"]  --config           The path to the config file                                                                                                         [string]  --options-path     The path to a JSON file with additional options                                                                                     [string]  --migrations-path  The path to the migrations folder                                                                           [string] [default: "migrations"]  --seeders-path     The path to the seeders folder                                                                                 [string] [default: "seeders"]  --models-path      The path to the models folder                                                                                   [string] [default: "models"]  --url              The database connection string to use. Alternative to using --config files                                                          [string]  --debug            When available show various debug information                                                                     [boolean] [default: false]  --charset          Pass charset option to dialect, MYSQL only                                                                                          [string]  --collate          Pass collate option to dialect                                                                                                      [string]  --encoding         Pass encoding option to dialect, PostgreSQL only                                                                                    [string]  --ctype            Pass ctype option to dialect, PostgreSQL only                                                                                       [string]  --template         Pass template option to dialect, PostgreSQL only                                                                                    [string]

TypeError: Cannot read properties of undefined (reading 'detail')
    at Object.error (C:\Users\user\Desktop\bootcamp_nodejs\99_teamstudy\wonbin\node_modules\sequelize-cli\lib\helpers\view-helper.js:31:24)
    at getDatabaseLessSequelize (C:\Users\user\Desktop\bootcamp_nodejs\99_teamstudy\wonbin\node_modules\sequelize-cli\lib\commands\database.js:75:27)
    at exports.handler (C:\Users\user\Desktop\bootcamp_nodejs\99_teamstudy\wonbin\node_modules\sequelize-cli\lib\commands\database.js:32:21)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

 

해결방법은 간단했다. 터미널창에서 config.json 파일이 있는 폴더로 이동한 후 sequealize db:create를 실행해야 한다.

터미널창 

C:\Users\user\Desktop\bootcamp_nodejs\99_teamstudy\wonbin\src>cd sequelize