Ts-node: Not sure how to compile es6 code

Created on 10 Sep 2018  路  1Comment  路  Source: TypeStrong/ts-node

I'm running: ts-node --project ./tsconfig.json downloadImages.ts

// tsconfig.json
{
  "compileOnSave": true,
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "moduleResolution": "node",
    "baseUrl": ".",
    "lib": [
      "dom",
      "es2015",
      "es2016",
      "es2017.object"
    ]
  }
}

I'm getting:

(function (exports, require, module, __filename, __dirname) { import request from 'request-promise';
                                                                     ^^^^^^^
SyntaxError: Unexpected identifier

I must be doing something wrong about declaring that the file is defined as ES6 code.

Most helpful comment

I changed compilerOptiosn to

{
  ...
  "target": "es6",
  "module": "esnext",// Deleted
  ...
}

and now it works.

>All comments

I changed compilerOptiosn to

{
  ...
  "target": "es6",
  "module": "esnext",// Deleted
  ...
}

and now it works.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sanex3339 picture sanex3339  路  4Comments

KiaraGrouwstra picture KiaraGrouwstra  路  3Comments

remojansen picture remojansen  路  4Comments

Borewit picture Borewit  路  3Comments

mattdell picture mattdell  路  4Comments