import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';
See original GitHub issueI’m submitting a bug relationed with entities.ts
[ ] Regression
[x ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
Running npm run start, i get:
C:\Projetos\project-name\src\api\user\user.entity.ts:1 [0] import { Entity, Column, PrimaryGeneratedColumn } from ‘typeorm’; [0] ^ [0] [0] SyntaxError: Unexpected token { [0] at Module._compile (internal/modules/cjs/loader.js:721:23) [0] at Object.Module._extensions…js (internal/modules/cjs/loader.js:787:10) [0] at Module.load (internal/modules/cjs/loader.js:653:32) [0] at tryModuleLoad (internal/modules/cjs/loader.js:593:12) [0] at Function.Module._load (internal/modules/cjs/loader.js:585:3) [0] at Module.require (internal/modules/cjs/loader.js:690:17) [0] at require (internal/modules/cjs/helpers.js:25:18) [0] at Function.PlatformTools.load (C:\Projetos\project-name\node_modules\typeorm\platform\PlatformTools.js:107:28) [0] at C:\Projetos\project-name\node_modules\typeorm\util\DirectoryExportedClassesLoader.js:30:69 [0] at Array.map (<anonymous>)
Expected behavior
Expected to run and interpret entity file, connect to database and run migrations or create tables for example.
Minimal reproduction of the problem with instructions
$ npm i -g @nestjs/cli $ nest new project-name
Next, follow these instructions: https://docs.nestjs.com/
Environment
Nest version: 6.5.0
For Tooling issues:
- Node version: v10.16.0
- Platform: Windows
Others:
*NPM*
{
"name": "project-name",
"version": "0.0.1",
"description": "",
"author": "",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"format": "prettier --write \"src/**/*.ts\"",
"start": "ts-node -r tsconfig-paths/register src/main.ts",
"start:dev": "concurrently --handle-input \"wait-on dist/main.js && nodemon\" \"tsc -w -p tsconfig.build.json\" ",
"start:debug": "nodemon --config nodemon-debug.json",
"prestart:prod": "rimraf dist && npm run build",
"start:prod": "node dist/main.js",
"lint": "tslint -p tsconfig.json -c tslint.json",
"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"
},
"dependencies": {
"@nest-modules/mailer": "^1.1.3",
"@nestjs/common": "^6.0.0",
"@nestjs/core": "^6.0.0",
"@nestjs/jwt": "^6.1.1",
"@nestjs/passport": "^6.1.0",
"@nestjs/platform-express": "^6.0.0",
"@nestjs/swagger": "^3.0.2",
"@nestjs/typeorm": "^6.0.0",
"@sentry/node": "^5.5.0",
"@types/bcrypt": "^3.0.0",
"@types/helmet": "0.0.43",
"@types/passport-jwt": "^3.0.1",
"bcrypt": "^3.0.6",
"class-transformer": "^0.2.3",
"class-validator": "^0.9.1",
"helmet": "^3.18.0",
"nestjs-config": "^1.4.2",
"passport": "^0.4.0",
"passport-jwt": "^4.0.0",
"pg": "^7.11.0",
"randomatic": "^3.1.1",
"reflect-metadata": "^0.1.12",
"rimraf": "^2.6.2",
"rxjs": "^6.3.3",
"typeorm": "^0.2.16"
},
"devDependencies": {
"@nestjs/testing": "^6.0.0",
"@types/express": "^4.16.0",
"@types/jest": "^23.3.13",
"@types/node": "^10.12.18",
"@types/nodemailer": "^6.2.0",
"@types/supertest": "^2.0.7",
"concurrently": "^4.1.0",
"jest": "^23.6.0",
"nodemon": "^1.18.9",
"prettier": "^1.15.3",
"supertest": "^3.4.1",
"ts-jest": "24.0.2",
"ts-node": "8.1.0",
"tsconfig-paths": "3.8.0",
"tslint": "5.16.0",
"typescript": "3.4.3",
"wait-on": "^3.2.0"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (3 by maintainers)
Excuse me that my English isn’t very good.
@Joebob12 you can’t set entities option in
ormconfig.json
. in production mode, the ts file will compiler to js and extract to dist directory.problem
your
ormconfig.json
’s entities option always point tosrc/**/*.entity.ts
.how to solve
set entities option in your code
also, you can use config service or
ormconfig.js
to solve this problemJust want to bump this up. I’m having this same issue.