Tôi mới sử dụng node.js Tôi vừa hoàn tất cài đặt nó trên máy tính của mình. Trên thực tế tôi đang làm theo một hướng dẫn trên tutorialspoint. Sau khi cài đặt, tôi được yêu cầu tạo tệp main.js và đặt mã sau vào tệp.Lỗi Node.js cho ví dụ Hello World
/* Hello, World! program in node.js */
console.log("Hello, World!")
Tôi đã thực thi tệp main.js bằng cách sử dụng trình thông dịch Node.js bằng cách nhập $ node main.js, Nhưng tôi có các lỗi sau.
SyntaxError: Unexpected identifierat Object.exports.createScript
(vm.js:24:10)
at REPLServer.defaultEval (repl.js:221:25)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer.<anonymous> (repl.js:412:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:210:10)
at REPLServer.Interface._line (readline.js:549:8)
at REPLServer.Interface._ttyWrite (readline.js:826:14)
Hãy giúp tôi. Cảm ơn bạn.
Tôi nghĩ, bạn đang chạy 'nút main.js' không phải từ trình bao, nhưng từ nút REPL) –
Có thể trùng lặp của [Node REPL ném SyntaxError: Số nhận dạng không mong muốn] (http://stackoverflow.com/questions/29227486/node-repl-throws-syntaxerror-unexpected-identifier) –