You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get Cannot use import statement outside module error. I'm familiar with this error, so I tried to solve it by adding type: "module" in package.json. It didn't solve it. So I researched and added target: "esnext" and module: "esnext" in tsconfig.json, but then I lost the ability to use Top Level Await. So my only option is Not Using Top Level Await and setting module: "commonjs" in tsconfig.json.
Context
A simple NodeJS/Express/TypeScript RESTful API.
OS version (is it docker or host?)
Windows 10 Home 10.0.19043 Build 19043
I've been using node --watch --experimental-specifier-resolution=node --loader ts-node/esm main.ts and EsNext in both module and target in tsconfig.json. Maybe it helps you.
Issue description
I get
Cannot use import statement outside module
error. I'm familiar with this error, so I tried to solve it by addingtype: "module"
inpackage.json
. It didn't solve it. So I researched and addedtarget: "esnext"
andmodule: "esnext"
intsconfig.json
, but then I lost the ability to useTop Level Await
. So my only option isNot Using Top Level Await
and settingmodule: "commonjs"
intsconfig.json
.Context
A simple NodeJS/Express/TypeScript RESTful API.
OS version (is it docker or host?)
Windows 10 Home 10.0.19043 Build 19043
ts-node-dev version
1.1.8
Did you try to run with ts-node?
No
Did you try to run with
--files
option enabled?No
Did you try to run with
--debug
option enabled?No
Do you have a repro example (git repo) with simple steps to reproduce your problem? Not at this time.
package.json:
Related Issue
#265
The text was updated successfully, but these errors were encountered: