[英]Node.js: Error: ENOENT: no such file or directory
I keep getting this message when I'm trying to connect to localhost:3000 (Visual Studio Code, Node JS).当我尝试连接到 localhost:3000(Visual Studio Code,Node JS)时,我不断收到此消息。 I am not sure how to correct this.Edit: I corrected my file to server.js but I am still getting the same message.我不确定如何更正。编辑:我将文件更正为 server.js,但我仍然收到相同的消息。 Any help is appreciated任何帮助表示赞赏
Here is my code for server.js这是我的 server.js 代码
const express = require('express');
const path = require('path');
let initial_path = path.join(__dirname, "public");
const app = express();
app.use(express.static(initial_path));
app.get('/', (req, res) => {
res.sendFile(path.join(initial_path, "home.html"));
})
app.listen("3000", () => {
console.log('listening......');
})
And my code for package.json还有我的 package.json 代码
{
"name": "bloggin-site",
"version": "1.0.0",
"main": "server.js",
"scripts": {
"start": "nodemon server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"express-fileupload": "^1.2.1",
"express.js": "^1.0.0",
"nodemon": "^2.0.15"
},
"devDependencies": {},
"description": ""
}
rename servor.js
to server.js
.将servor.js
重命名为server.js
。 I faced a lot when I am learning programming) Good luck bro keep it up!我在学习编程时遇到了很多问题)祝兄弟继续努力!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.