[英]“node filename.js” is not working in vs code
I created a hello.js file in vs code containing a console.log
, and when I type in the terminal node hello.js
I get the following error:我在包含
console.log
的 vs 代码中创建了一个 hello.js 文件,当我输入终端node hello.js
时,出现以下错误:
SyntaxError: Invalid or unexpected token
at Module._compile (internal/modules/cjs/loader.js:721:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
The content of my js file:我的js文件内容:
console.log("hello");
Is it because vs code?是因为vs代码吗? Should I use another IDE?
我应该使用另一个 IDE 吗?
UPDATE: The problem also persists with Node.js Command Prompt更新: Node.js 命令提示符也存在问题
UPDATE2: I created the same file again with Sublime Text instead of VS Code and it works.. it was probably a bug from VS Code UPDATE2:我用 Sublime Text 而不是 VS Code 再次创建了同一个文件,它可以工作..这可能是 VS Code 的一个错误
Where's your hello.js file code?你的 hello.js 文件代码在哪里? Did you have the proper code?
你有正确的代码吗?
Example:例子:
hello.js file (make sure you save the file): hello.js 文件(确保保存文件):
console.log('Hello')
Open terminal in vs code (visual studio code), or hotkey press ctrl + ` (this ` key is next to number 1 on your keyboard), or go to top menu View > Terminal.在 vs 代码(Visual Studio 代码)中打开终端,或热键按 ctrl + `(此 ` 键在键盘上的数字 1 旁边),或 go 到顶部菜单视图 > 终端。
Type node hello键入节点你好
It will output: Hello它将 output: 你好
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.