跳转到内容

使用 Node.js 运行代码

执行 js 文件

在命令行中输入 node <文件地址> 即可运行 js 文件。

bash
node a.js

终端模式

在终端中输入 node 回车,进入终端模式,可以在终端直接输入 js 代码并立即运行。

bash
node
js
console.log('hello world')

按两次 ctrl + c 或输入 .exit 退出终端模式。