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 Answers1

0

You need to run the javascript file node FirstProgram.js

mamichels
  • 619
  • 4
  • 12