When you generate the starter with the TypeORM option it doesn't set up everything necessary to work with typeORM, using npx typeorm ... response with the following error:
C:\Users\me\git\project\src\entities\conferences.entity.ts:1
import { IsNotEmpty } from 'class-validator';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1032:15)
at Module._compile (node:internal/modules/cjs/loader:1067:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at C:\Users\derek_000\git\nilo-backend\node_modules\typeorm\util\ImportUtils.js:29:52
at step (C:\Users\derek_000\git\nilo-backend\node_modules\tslib\tslib.js:143:27)
Version to Reproduce (현재 사용한 버전)
starter version 9.1.1
Steps to Reproduce (재현 순서)
run the starter tool
choose typeORM
go to the project in your CLI
attempt to generate/run a migration with typeORM CLI npx typeorm migration:generate
Expected Behavior (예상 동작)
typeORM CLI functions should work
Actual Behavior (실제 동작)
typeORM CLI commands won't run, typeORM can't find DB connection information
Additional Context (추가 사항)
I fixed it with the following steps.
Add ormconfig.json to the root of the project directory for typeorm to find connection info
Describe the Bug (버그 설명)
When you generate the starter with the TypeORM option it doesn't set up everything necessary to work with typeORM, using
npx typeorm ...
response with the following error:Version to Reproduce (현재 사용한 버전)
starter version 9.1.1
Steps to Reproduce (재현 순서)
npx typeorm migration:generate
Expected Behavior (예상 동작)
typeORM CLI functions should work
Actual Behavior (실제 동작)
typeORM CLI commands won't run, typeORM can't find DB connection information
Additional Context (추가 사항)
I fixed it with the following steps.
ormconfig.json
to the root of the project directory for typeorm to find connection infopackage.json
:"typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js"
now you can generate migrations with
npm run typeorm -- migration:generate
and run them withnpm run typeorm -- migration:run