首页 > 解决方案 > 我在 Windows 终端上执行 JavaScript 文件时遇到问题

问题描述

我是 node.js 的新手,我的代码没有执行。无论我在哪里搜索它,我都意识到代码具有正确的语法。当我直接在终端上运行此代码时,它正在执行,但是当我创建一个名为 hello.js 的文件然后执行时,它给了我错误。代码和错误分别如下:

console.log('hello world');

抛出:

node hello.js

SyntaxError: Unexpected identifier

标签: javascriptnode.js

解决方案


推荐阅读