TypeORM Entity in NESTJS - Cannot use import statement outside a module

后端 未结 10 1827
甜味超标
甜味超标 2020-12-03 10:01

Started new project with \'nest new\' command. Works fine until I add entity file to it.

Got following error:

import { Entity, Column, Primary

10条回答
  •  半阙折子戏
    2020-12-03 10:31

    Actually, typeorm was designed to work with javascript by default.

    To run the migrations with typescript, you must tell typeorm to do it.

    Just put in your package.json, in the scripts part this line below:

    "typeorm": "ts-node-dev ./node_modules/typeorm/cli.js"
    

    and then, try to migrate again:

    yarn typeorm migration:run
    

提交回复
热议问题