node.js - 无法使用终端执行我的 node.js 代码
问题描述
我已经安装了 Node.js 版本 10.16.0 LTS。我在 cmd 中运行“node -v”命令来检查它是否安装正确。
创建了一个文件 hello.js 在同一目录下运行 cmd
错误消息说: D:\nodeJS>node
node hello.js 抛出:node hello.js ^^^^^ SyntaxError: Unexpected identifier
我在 .js 文件中编写的唯一代码行是:console.log("hello");
for(var i = 0; i < 10; i++){
console.log("hello");
}
解决方案
您在节点 REPL 中运行它。按 control + c 两次退出 Node REPL。然后你运行命令node hello.js
推荐阅读
- sql-server - 两个月前的数据
- c# - 连接字符串的密码
- php - 单击按钮时,Codeigniter 不会将输入表单重定向到仪表板
- jquery - WooCommerce jQuery 在页面上工作,但不在相同按钮的弹出窗口中
- spring - Spring Boot REST - 使用 OData 从 Microsoft Dynamics NAV 中提取数据
- python - 如何在python中数值求解差分方程
- python - 用于列出基于选择日期创建的 EBS 快照的 python 脚本
- arrays - Angular 5:根据属性获取数组的所有对象
- react-native - 在 create-react-native-app 项目中突然看到错误“插件/预设文件不允许导出对象,只有功能”
- javascript - Vue.js 的问题:不显示数据