[webpack start:hmr] SyntaxError: Unexpected token import on TypeORM entity files
See original GitHub issueI’m submitting a…
[ ] 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
When running npm run start:hmr
(note that npm run webpack
is running) on a project created with the CLI and containing a TypeORM entity file, I get the following error:
[Nest] 10906 - 2018-8-29 16:41:14 [TypeOrmModule] Unable to connect to the database. Retrying (6)... +3011ms
/mnt/c/********/src/records/record.entity.ts:1
(function (exports, require, module, __filename, __dirname) { import { Entity, Column, PrimaryGeneratedColumn, VersionColumn, CreateDateColumn,
UpdateDateColumn } from 'typeorm';
^^^^^^
SyntaxError: Unexpected token import
Expected behavior
I would expect no errors. It seems like the entity file does not get compiled to JavaScript.
Minimal reproduction of the problem with instructions
- Create a new project with the Nest CLI
- Add TypeORM to the project
- Create a TypeORM entity file
- Run
npm run webpack
- On another terminal run
npm run start:hmr
- Observe the error
What is the motivation / use case for changing the behavior?
Environment
[System Information]
OS Version : Linux 4.4
NodeJS Version : v8.11.4
NPM Version : 6.4.0
[Nest Information]
typeorm version : 5.2.0
common version : 5.0.0
core version : 5.0.0
I am new to Nest so please excuse me If I am making a stupid mistake. I was not able to find details in the documentation about hot reloading on a CLI project. Thanks!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:11 (1 by maintainers)
Top Results From Across the Web
TypeORM + Webpack causes SyntaxError: Unexpected token ...
The problem seems to be related to the fact that ormconfig.json is referring to .ts entity files. Solution in similar threads seems to...
Read more >Unexpected token error from Webpack compiling React-node.js
You get this error if webpack can't find your .babelrc . Make sure you don't have a typo in the filename. You can...
Read more >jest uuid syntaxerror: unexpected token 'export' - You.com
This means, that a file is not transformed through TypeScript compiler, e.g. because it is a JS file with TS syntax, or it...
Read more >nrwl-nx/community - Gitter
Test suite failed to run Jest encountered an unexpected token This usually means that you are trying to import a file which Jest...
Read more >Hsqldb Unexpected Token: Getdate - ADocLib
Error: Unexpected token Entity name java sql hibernate hsqldb. ... [webpack start:hmr] SyntaxError: Unexpected token import on TypeORM entity What is the ...
Read more >Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi Guys,
I’m able to fix this issue by changing configuration in nodemon.json as below.
nodemon.json
another option would be to create the
./src/orm.config.ts
I have to import all the entities there and then add it in the main module.app.module.ts
File orm.config.ts