소개
게시글
질문&답변
2024.10.06
yarn seed 명령어 실행 시 데이터 삽입 안됨
해결하였습니다.해결방법은 우선 아래 명령어를 통해 재설치를 하였습니다.npm i -D ts-node그리고 package.json 파일을 아래와 같이 수정하였습니다. "typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js", "db:create": "ts-node ./node_modules/typeorm-extension/dist/cli/index.js db:create -d ./dataSource.ts", "db:drop": "ts-node ./node_modules/typeorm-extension/dist/cli/index.js db:drop -d ./dataSource.ts", "seed": "ts-node ./node_modules/typeorm-extension/bin/cli.cjs seed:run -d ./dataSource.ts", "schema:drop": "ts-node ./node_modules/typeorm/cli.js schema:drop", "schema:sync": "ts-node ./node_modules/typeorm/cli.js schema:sync", "db:migrate": "npm run typeorm migration:run -- -d ./dataSource.ts", "db:migrate:revert": "npm run typeorm migration:revert -- -d ./dataSource.ts", "db:create-migration": "npm run typeorm migration:create -- ./src/migrations/", "db:generate-migration": "npm run typeorm migration:generate -- ./src/migrations -d ./dataSource.ts"그 다음 스키마를 완전 삭제 후 스키마를 다시 생성 후yarn run start:dev를 통해 테이블을 만들어주고 yarn seed 명령어를 입력하니 데이터가 생성되었습니다.
- 0
- 4
- 89
질문&답변
2024.10.06
yarn seed 명령어 실행 시 데이터 삽입 안됨
{ "name": "nest", "version": "0.0.1", "description": "", "author": "", "private": true, "license": "UNLICENSED", "scripts": { "build": "nest build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", "start": "nest start", "start:dev-backup": "nest start --watch", "start:dev": "nest build --webpack --webpackPath webpack-hmr.config.js --watch", "start:debug": "nest start --debug --watch", "start:prod": "node dist/main", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", "test": "jest", "test:watch": "jest --watch", "test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:e2e": "jest --config ./test/jest-e2e.json", "typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js", "db:create": "ts-node ./node_modules/typeorm-extension/bin/cli.cjs db:create -d ./dataSource.ts", "db:drop": "ts-node ./node_modules/typeorm-extension/bin/cli.cjs db:drop -d ./dataSource.ts", "seed": "ts-node ./node_modules/typeorm-extension seed:run -d ./dist/dataSource.js", "schema:drop": "ts-node ./node_modules/typeorm/cli.js schema:drop", "schema:sync": "ts-node ./node_modules/typeorm/cli.js schema:sync", "db:migrate": "npm run typeorm migration:run -- -d ./dataSource.ts", "db:migrate:revert": "npm run typeorm migration:revert -- -d ./dataSource.ts", "db:create-migration": "npm run typeorm migration:create -- ./src/migrations/", "db:generate-migration": "npm run typeorm migration:generate -- ./src/migrations -d ./dataSource.ts" }, "dependencies": { "@nestjs/common": "^9.0.1", "@nestjs/config": "^2.2.0", "@nestjs/core": "^9.0.1", "@nestjs/platform-express": "^9.0.1", "@nestjs/swagger": "^7.4.2", "@nestjs/typeorm": "^9.0.0", "class-transformer": "^0.5.1", "cliui": "7", "dotenv": "^16.4.5", "mysql2": "^3.11.3", "reflect-metadata": "^0.1.13", "rxjs": "^7.3.0", "typeorm": "^0.3.0", "typeorm-extension": "^3.6.1", "wrap-ansi": "6", "yargs": "16" }, "devDependencies": { "@nestjs/cli": "^9.0.0", "@nestjs/schematics": "^9.0.1", "@nestjs/testing": "^9.0.1", "@types/express": "^4.17.8", "@types/jest": "^29.5.2", "@types/node": "^14.17.11", "@types/supertest": "^2.0.12", "@typescript-eslint/eslint-plugin": "^4.15.2", "@typescript-eslint/parser": "^4.15.2", "eslint": "^7.12.1", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^3.1.4", "jest": "^29.5.0", "prettier": "^3.0.0", "run-script-webpack-plugin": "^0.2.0", "source-map-support": "^0.5.21", "supertest": "^6.3.3", "ts-jest": "^29.1.0", "ts-loader": "^9.4.3", "ts-node": "^10.2.1", "tsconfig-paths": "^3.9.0", "typeorm-model-generator": "^0.4.6", "typescript": "^5.6.2", "webpack": "^5.95.0", "webpack-node-externals": "^3.0.0" }, "jest": { "moduleFileExtensions": [ "js", "json", "ts" ], "rootDir": "src", "testRegex": ".*\\.spec\\.ts$", "transform": { "^.+\\.(t|j)s$": "ts-jest" }, "collectCoverageFrom": [ "**/*.(t|j)s" ], "coverageDirectory": "../coverage", "testEnvironment": "node" } }참고로 package.json파일입니다.
- 0
- 4
- 89