jSu*_*e90 5 javascript node.js angularjs
我一直在遵循scotch.io教程来创建我的第一个节点和angular应用程序。我已经看到相对路径是在线上的常见问题Error: ENOENT: no such file or directory,据我所知,它与本教程相同,所以我为什么不起作用。
完整的错误消息是:
Error: ENOENT: no such file or directory, stat'/Users/badman/githubRepos/travelGuide/app/public/index.html'
at Error (native)
我的文件夹结构在这里。 我的server.js:
// set up web server
var express = require('express');
var app = express();
var bodyParser = require("body-parser");
// routes
require('./app/routes.js')(app);
// listen (start app with node server.js)
app.listen(3000, function() {
console.log("server going");
})
Run Code Online (Sandbox Code Playgroud)
route.js:
module.exports = function (app) {
app.get('*', function (req, res) {
res.sendFile(__dirname + '/public/index.html'); // load the single view file (angular will handle the page changes on the front-end)
});
};
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏:)
我遇到了同样的问题,然后我搬家了
app.get('*', function (req, res) {
res.sendFile(__dirname + '/public/index.html'); // load the single view file (angular will handle the page changes on the front-end)
});
Run Code Online (Sandbox Code Playgroud)
到server.js 的正下方require('./app/routes.js')(app);并修复它!因为当调用服务器端路由时,它在错误的位置寻找index.html 。我认为你也可以改变路径,但我发现这更清晰。
| 归档时间: |
|
| 查看次数: |
5266 次 |
| 最近记录: |