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 am a newbie in TS & want to run a single line programme directly without tanspiling via ts-node These are my specs
I ran below command
npm install -g typescript
npm install -g ts-node
This is my code
Console.log("Hello World");
I am getting below error
PS G:\New folder> ts-node "g:\New folder\Session1.ts"
(node:5020) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
g:\New folder\Session1.ts:2
export {};
^^^^^^
SyntaxError: Unexpected token 'export'
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1178:20)
at Module._compile (node:internal/modules/cjs/loader:1220:27)
at Module.m._compile (C:\Users\user\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:1618:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Object.require.extensions.<computed> [as .ts] (C:\Users\user\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:1621:12)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Function.Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at phase4 (C:\Users\user\AppData\Roaming\npm\node_modules\ts-node\src\bin.ts:649:14)
I am not doing any import nothing, I think it should work without package.json file and even after adding package.json file the problem still persists....Please help me with this.
reacted with thumbs up emojireacted with thumbs down emojireacted with laugh emojireacted with hooray emojireacted with confused emojireacted with heart emojireacted with rocket emojireacted with eyes emoji
-
I am a newbie in TS & want to run a single line programme directly without tanspiling via ts-node

These are my specs
I ran below command
This is my code
I am getting below error
I am not doing any import nothing, I think it should work without package.json file and even after adding package.json file the problem still persists....Please help me with this.
Thank You
Beta Was this translation helpful? Give feedback.
All reactions