codestates / codestates/SIMSIMAE-server

[Error] sequelize-auto 사용시 init-models.js import 오류

Open
#62 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

completed error
Dominant language
JavaScript
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

어떤 에러인가요?!

init-models.js 파일을 사용하고자 하는 js 파일에서 import해서 불러왔을 때 sequelize is not defined에러 발생

image

const initModels = require('../../models/init-models');
const models = initModels
에러 핸들링 방법

방법1)

  • 아래와 같이 sequelize를 import 해왔는데 sequelize is not a function 오류 발생
const sequelize = require('sequelize')

방법2) - solution

  • sequelize를 models 디렉토리에서 import 해왔더니 init-models.js를 불러와 연동된 테이블을 불러올 수 있었다.
const { sequelize } = require('../../models');
const initModels = require('../../models/init-models');
에러 핸들링을 위해 참고한 레퍼런스 링크

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the import from the issue with models/init-models.js and the models directory export. Compare the failing direct import with the shown require('../../models') workaround, and consult the linked sequelize-auto issue and package documentation. Done means the intended import path and expected behavior are clearly established and verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.