Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ts-node doesn't work when I use esnext in module generator. #510

Closed
gkawin opened this issue Jan 12, 2018 · 1 comment
Closed

ts-node doesn't work when I use esnext in module generator. #510

gkawin opened this issue Jan 12, 2018 · 1 comment

Comments

@gkawin
Copy link

gkawin commented Jan 12, 2018

I specify the module generator in tsconfig.json to esnext. I doesn't work. I got an error log like this

(function (exports, require, module, __filename, __dirname) { import * as Express from "express";
                                                              ^^^^^^

SyntaxError: Unexpected token import
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:599:28)
    at Module.m._compile (C:\Users\KawinGlomjai\axia-insurance-website\node_modules\ts-node\src\index.ts:422:23)
    at Module._extensions..js (module.js:646:10)
    at Object.require.extensions.(anonymous function) [as .ts] (C:\Users\KawinGlomjai\axia-insurance-website\node_modules\ts-node\src\index.ts:425:12)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.Module.runMain (module.js:676:10)

in the other hand, i change to commonjs It pretty work fine. unless I change the whole import codes to import React from 'react' to import * as React from 'react' instead. Do you have any idea how to work on esnext module?

@blakeembrey
Copy link
Member

Node.js would need to support ESNext modules and I believe there's a long discussion in #436 about figuring out how to support it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants