Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filepath error using sendFile instead of sendfile #6

Open
AndrewSouthpaw opened this issue Sep 13, 2014 · 3 comments
Open

Filepath error using sendFile instead of sendfile #6

AndrewSouthpaw opened this issue Sep 13, 2014 · 3 comments

Comments

@AndrewSouthpaw
Copy link

The tutorial is inconsistent about using res.sendfile or res.sendFile. If res.sendFile is used (since sendfile is deprecated), using

res.sendFile('index.html');

doesn't work, throwing an error about the path not being specified properly. Here's what I did to fix it:

res.sendFile(__dirname + '/index.html');

@evertonbaima
Copy link

Another way:

var path = require('path');

app.get('/', function (req, res) {
    res.sendFile(path.resolve('index.html'));
});

@MikeiLL
Copy link

MikeiLL commented Sep 30, 2014

For some reason I'm getting error TypeError: Object #<ServerResponse> has no method 'sendFile' at Object.handle when I try either of the above methods.

@MikeiLL
Copy link

MikeiLL commented Sep 30, 2014

Ah. Had an older of express installed (maybe based on the package.json file from repository.
Express docs
Note: res.sendFile requires Express version to be at least 4.8.0

TheSachinSBhat added a commit to TheSachinSBhat/chat-example-1 that referenced this issue Feb 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants