yntaxError: Cannot use import statement outside a module at wrapSafe (internal/modules/cjs/loader.js:979:16)
hybitu opened this issue · 1 comments
Hello!
I had a fresh start Nest Project, created with command
$ npm i -g @nestjs/cli $ nest new project-name
After that I created a module with command
$ nest g resource
Then I created an Entity using TypeOrm. I loaded that entity in file ormconfig.json in the property "entities": ["src/**/entities/*.entity{.ts,.js}"],
When I start the project I got the error:
`[ExceptionHandler] Cannot use import statement outside a module +2ms
/home/user/projects/project/src/module/entities/entity.entity.ts:1
import {Entity, Column, PrimaryGeneratedColumn, CreateDateColumn} from "typeorm";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at /home/user/projects/project/node_modules/typeorm/util/DirectoryExportedClassesLoader.js:41:39
at Array.map ()
at Object.importClassesFromDirectories (/home/user/projects/project/node_modules/typeorm/util/DirectoryExportedClassesLoader.js:41:10)`