gpt4 book ai didi

node.js - 不能在 Node 中说 Hello World

转载 作者:行者123 更新时间:2023-12-04 19:04:16 27 4
gpt4 key购买 nike

我正在尝试遵循以下教程 Node Beginner Book

我已经成功安装了node和mongodb,当我做node -v它给了我v0.5.11-pre但是当我保存文件时说hello.jsHome/node/并写node hello.js在终端它给了我以下错误

ubuntu@ubuntu:~/Downloads$ node hello.js

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^ Error: Cannot find module '/home/ubuntu/Downloads/hello.js'
at Function._resolveFilename (module.js:334:11)
at Function._load (module.js:279:25)
at Array.0 (module.js:470:10)
at EventEmitter._tickCallback (node.js:192:40)

请帮我找出我在这里做错了什么。我在虚拟机中使用 Ubuntu。

最佳答案

你在错误的目录中。移动到 hello.js 所在的文件与 cd , 像这样:

cd $HOME/node
node hello.js

关于node.js - 不能在 Node 中说 Hello World,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10332797/

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