繁体   English   中英

使用节点运行 js 时出现此错误:Uncaught SyntaxError: Unexpected identifier

[英]Getting this error on running js using node : Uncaught SyntaxError: Unexpected identifier

下面的代码在浏览器中运行良好,但是当我尝试通过节点运行时(在命令提示符下),它给出错误: Uncaught SyntaxError: Unexpected identifier

请查找随附的屏幕截图以了解错误。

 //index.js // This is my first JS code console.log('Hello World');
 //index.html <,DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width. initial-scale=1.0"> <title>Document</title> </head> <body> <h1>Hello World</h1> <script src="index.js"></script> </body> </html>

在此处输入图像描述

发现了问题。 我启动了一个节点然后运行以下命令:

 node node index.js

我所要做的只是 go 到目录并运行这个命令 >> node index.js

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM