inflearn logo
강의

講義

知識共有

Slackクローンコーディング[バックエンド with NestJS + TypeORM]

typeorm seeding, migration

seed 생성 에러

解決済みの質問

772

작성자 없음

投稿した質問数 0

0

안녕하세요.

npm run seed:run 을하면 

 

🌱  TypeORM Seeding v1.6.1

✖ Could not load the config file!

TypeORMError: No connection options were found in any orm configuration files.

 

이런 에러가 발생해서

제로초님 깃허브로 전부 복사해도 똑같이 해결이안되는데 이유를 혹시 아시나요?

메세지를 보면 ormconfig.ts를 못찾는거같아요.

.env도 입력했고 프론트도 들어서 강의그대로 자동생성 진행했고, entities폴더도 깃허브로 바꿨어요. 그리고 package.json, ormconfig,create-initial-data 이런거 전부 복사해서 다시 해보고 경로도 맞아서 오타문제는 아닌거같은데..

 

 forRoot()부분에 옵션을 직접 넣어보기도 하고

엔티티부분을

entities: ["entities/*.js"] 이거도 해보고

entities: ["dist/**/**.entity{.ts,.js}"이렇게 바꿔보기도

package.json의 typeorm부분을

"typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js --config src/ormconfig.ts",

이랗게 바꿔보기도 했는데 에러는 그대로 여서 잘 모르겠네용

 

express nodejs TypeORM NestJS

回答 4

0

chaosts9990

🌱  TypeORM Seeding v1.6.1

✖ Could not load the config file!

TypeORMError: No connection options were found in any orm configuration files.

에러 원인 

ormconfig.ts을 밖으로 빼서 설정해주지 않으면 에러가 발생하네요 

0

kimssun

Error: Nest can't resolve dependencies of the ShopsService (ShopsRepository, ?). Please make sure that the argument UsersRepository at index [1] is available in the ShopsModule context.

 

Potential solutions:

- If UsersRepository is a provider, is it part of the current ShopsModule?

- If UsersRepository is exported from a separate @Module, is that module imported within ShopsModule?

  @Module({

    imports: [ /* the Module containing UsersRepository */ ]

  })

 

 

제로초님 이부분이 왜 에러가 나는것일까요..? 강의들으면서 궁금했습니다..

 

import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Shops } from 'src/entities/shops.entity';
import { ShopsController } from './shops.controller';
import { ShopsService } from './shops.service';

@Module({
imports: [TypeOrmModule.forFeature([Shops])],
controllers: [ShopsController],
providers: [ShopsService],
})
export class ShopsModule {}

0

kimssun

제로초님 혹시 npm i typeorm-seeding 현재 이 명령어가 먹히질 않아서 그러는데 버전이 업데이트된것일까요 ?

0

zerocho

어떤 에러메시지가 뜨시나요?

0

kimssun

npm err! 하면서 에러가 나오는데 제가 자세하게 캡쳐해서 드릴게요 ㅠㅠ

0

kimssun

제로초님 그리고 하나만 더 여쭤봐도될까요 ? 

//유저 상세정보 조회
async getUser(email: string) {
const getUser = await this.usersRepository
.createQueryBuilder()
.select(['tbl_user.email', 'tbl_user.user_name', 'tbl_user.gender'])
.from(Users, 'tbl_user')
.where('tbl_user.email = :email', { email })
.getOne();
if (!getUser) {
throw new BadRequestException('존재하지 않는 유저입니다.');
}
return getUser;
} 서비스쪽 로직입니다..
 
 
 
//컨트롤러
@ApiOperation({ summary: '내 정보 조회' })
@Get(':id')
async getUsers(@Param('email') email: string) {
return await this.usersService.getUser(email);
}
했는데 왜 해당쿼리 where절에서 ?값으로 Undefined가 찍히는지 이해가 안돼네요.. ㅋㅋㅋ 강의보면서 혼자 따로 만들어보고있는데

0

zerocho

email이 undefined인 것 아닌가요?

@Get(':id')인데 @Param('email') 이네요.

0

kimssun

네 맞습니다 ㅠㅠ 전 email로 만들어 주었거든요.. 

0

zerocho

@Get(':email') 하셔야죠

0

kimssun

그런데 service쪽에 이렇게 넣어주면 .where('tbl_user.email = :email', { email: 'dfadsfa@dafassaf.com'})

0

kimssun

.where('tbl_user.email = :email', { email: 'dfadsfa@dafassaf.com'}) 이렇게 넣어주면 동작은하네요

0

zerocho

--config 부분을 typeorm 명령어 말고 seed:run에 추가해보세요.

그리고 .env에 다음것 말고도 db 연결 정보도 들어있으신가요?

TYPEORM_SEEDING_FACTORIES=src/factories/**/*{.ts,.js}
TYPEORM_SEEDING_SEEDS=src/seeds/**/*{.ts,.js}

0

zerocho

음.. 제 깃허브로 해보니 됩니다. ㅠㅠ 코드와 버전이 같은지 한 번 더 확인해주세요.

강의자료는 어디서 다운받나요?

0

110

3

질문 있습니다.

0

294

3

코드 편집기 확장 프로그램

0

209

2

(질문)비밀 저장소에 접근하기 위한 인증 정보는 로컬 .env에 저장하는지?

0

143

2

(질문)외부 저장소를 통한 환경변수 불러오기 비동기 질문

0

166

3

로그인을 해도 LoggedInGuard쪽에서 false값이 나옵니다.

0

151

2

로그인방법이 고민됩니다.

0

190

2

yarn seed 명령어 실행 시 데이터 삽입 안됨

0

296

4

yarn run db:create 시에 발생하는 데코레이터 오류

0

242

2

npm run db:create 시에 발생하는 decorating 오류

0

231

2

RxJS 디버깅 질문 있습니다.

0

187

3

CacheManager에 대해 질문 있습니다.

0

173

2

로깅은 어떻게 하는게 효율적일까요?

0

222

1

CORS 질문 있습니다.

0

416

2

쿠키 옵션에 대해서 질문 있습니다.

0

184

2

로그아웃 요청이 403 forbidden 에러가 나는데 왜그런걸까요??

0

446

1

401 unauthorized문제

0

285

1

가드의 장점에 대해서 질문이 있습니다.

0

225

1

로그 관리에 대해 질문 있습니다.

0

251

2

CORS 에러 질문 있습니다.

0

317

2

배포 환경 DB 연결 질문 있습니다.

0

410

2

socket io 미 연결 문제 (nest & flutter)

1

1150

3

no elements in sequence 에러 관해서 질문이 있습니다.

0

451

1

start:dev-backup으로 돌리면 핫 리로딩이 되요 정상인가요?

0

319

1