gpt4 book ai didi

node.js - 无法运行简单的 HelloWorld node.js 脚本

转载 作者:搜寻专家 更新时间:2023-11-01 00:26:10 24 4
gpt4 key购买 nike

我刚刚在我的 ubuntu 笔记本电脑上安装了 node.js。

我按照此处的说明进行操作:http://davidtsadler.com/archives/2012/05/06/installing-node-js-on-ubuntu/#application并从 git 存储库安装

安装没有错误,但是当我运行 server.js 示例应用程序时没有任何反应。

更糟糕的是,我尝试运行一个名为 hello.js 的非常基本的 hello world 脚本

console.log("hello world");

当我输入:node hello.js

没有任何反应,没有错误消息,没有任何内容写入控制台窗口。

ubuntu 上的 Node 是否存在任何已知问题?

谢谢

编辑

如果我输入,就会在终端中注意到:

node console.log("hello world");

我明白了

$ node console.log("hi");

bash: 意外标记 `(' 附近的语法错误

最佳答案

像这样运行你的文件

node <your_file>.js

或者把这个加在上面 #!/usr/bin/env node

关于node.js - 无法运行简单的 HelloWorld node.js 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15235039/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com