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
** 我能够编译此代码,但在运行时出现错误。我可以知道解决方案吗?
答案 0 :(得分:0)
您需要运行JavaScript文件node FirstProgram.js