TypeScript-Node-Starter icon indicating copy to clipboard operation
TypeScript-Node-Starter copied to clipboard

Cannot use import statement outside a module

Open aryeh-luwfy opened this issue 5 years ago • 1 comments
trafficstars

compiling error in file inside folder in src directory

[Node] SyntaxError: Cannot use import statement outside a module
[Node]     at Module._compile (internal/modules/cjs/loader.js:892:18)
[Node]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
[Node]     at Module.load (internal/modules/cjs/loader.js:812:32)
[Node]     at Function.Module._load (internal/modules/cjs/loader.js:724:14)
[Node]     at Module.require (internal/modules/cjs/loader.js:849:19)
[Node]     at require (internal/modules/cjs/helpers.js:74:18)

aryeh-luwfy avatar Dec 23 '19 11:12 aryeh-luwfy

I don't know if is to late to help, can you check your tsconfig file if you set the right specification on target & module.

"target":  "ES VERSION THAT YOU ARE CURRENT USING"  /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */

"module":  "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */

lopesboa avatar Mar 30 '20 17:03 lopesboa