Closed taekyun-yoon closed 5 months ago
typeorm-extension 패키지의 CLI 진입점의 파일 위치가 dist/cli/index.js 가 아니라, ./node_modules/typeorm-extension/dist/cli/index.js 입니다. 따라서 "ts-node -r tsconfig-paths/register ./node_modules/typeorm-extension/bin/cli.cjs seed: run"로 수정 참고:https://www.npmjs.com/package/typeorm-extension (usage 부분)
nest-board git:(main) ✗ yarn seed yarn run v1.22.22 warning ../../../../package.json: No license field $ ts-node ./node_modules/typeorm-extension/bin/cli.cjs seed:run -d src/data-source.ts ℹ DataSource Directory: /Users/yuntaegyun/Desktop/TAE/nestjs/nest-board/src 10:05:22 AM ℹ DataSource Name: data-source.ts 10:05:22 AM typeorm-extension seed:run
Populate the database with an initial data set or generated data by a factory.
Options: -h, --help Show help [boolean] --preserveFilePaths This option indicates if file paths should be preserved. [boolean] [default: false] -r, --root Root directory of the project. [default: "/Users/yuntaegyun/Desktop/TAE/nestjs/nest-board"] --tsconfig, --tc Name (or relative path incl. name) of the tsconfig file. [default: "tsconfig.json"] -d, --dataSource Name (or relative path incl. name) of the data-source file. [default: "data-source"] -n, --name Name (or relative path incl. name) of the seeder. -v, --version Show version number [boolean]
Error: Cannot find module 'src/entity/user.entity' Require stack:
Error: Cannot find module 'src/entity/user.entity'
import { User } from 'src/entity/user.entity'; 와 같이 import 시, 절대 경로 사용하면 tsconfig.json 에 { "compilerOptions": { "baseUrl": "./", "paths": { "src/": ["src/"] } } }
추가 필요 반대로, import { User } from './entity/user.entity'; 과 같이 상대경로 사용시, 추가하지 않아도 됩니다. 현재는 전자의 경우로 tsconfig.json 에 path 설정을 추가하여 해결
기존의 "seed": "ts-node -r tsconfig-paths/register ./node_modules/typeorm-extension/dist/cli/index.js seed" 명령어에서 오류 발생
nest-board git:(main) ✗ yarn run seed yarn run v1.22.22 warning ../../../../package.json: No license field $ ts-node -r tsconfig-paths/register ./node_modules/typeorm-extension/dist/cli/cjs.js seed node:internal/modules/cjs/loader:1189 throw err; ^
Error: Cannot find module './cjs.js' Require stack:
Node.js v22.2.0