0
class FirstProgram {
    name:string = "abc"
}

let fp = new FirstProgram()
console.log(fp.name)

**

PS E:\typescript> tsc FirstProgram.ts
PS E:\typescript> node FirstProgram.ts
E:\typescript\FirstProgram.ts:3
    name:string = "abc"


SyntaxError: Unexpected identifier
[90m    at wrapSafe (internal/modules/cjs/loader.js:1054:16)?[39m
[90m    at Module._compile (internal/modules/cjs/loader.js:1102:27)?[39m
[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)?[39m
[90m    at Module.load (internal/modules/cjs/loader.js:986:32)?[39m
[90m    at Function.Module._load (internal/modules/cjs/loader.js:879:14)?[39m
[90m    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)?[39m
[90m    at internal/main/run_main_module.js:17:47?[39m

** I am able to compile this code but getting error at the run time. May I know the solution for this?

1
  • Thanks, this helps me to run the code. Commented Jul 16, 2020 at 9:06

1 Answer 1

0

You need to run the javascript file node FirstProgram.js

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.