Type-graphql: Unexpected token import

Created on 21 Sep 2018  路  1Comment  路  Source: MichalLytek/type-graphql

Hi,

I build my project with tsc, when i run this project (node dist/server.js), i've got this error :
Unexpected token {
(function (exports, require, module, __filename, __dirname) { import { Field, ID, Int, ObjectType } from 'type-graphql';

My tsconfig.json :

{
  "include": [
    "src/**/*.ts"
  ],
  "compilerOptions": {
    "target": "es2016",
    "module": "commonjs",
    "outDir": "dist",
    "rootDir": "src",
    "baseUrl": ".",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": ["es2016", "esnext.asynciterable"]
  }
}

Could you help me to resolve this bug ?
Thanks

Question Solved

>All comments

Sorry, but GitHub issues are not a helpdesk.
Please ask your question on gitter or better at stackoverflow as the problem is not a type-graphql's fault but you need to setup your tsconfig properly to transpile import statements into require as Node.js doesn't support ES6 modules in .js files, only in .mjs.

Was this page helpful?
0 / 5 - 0 ratings