Since both the server and the index file are INSIDE the “public” directory, you can simply use :
res.sendfile('./main.html');
To answer the question in the comments : In Express 4.x, the sendfile
method was replaced by the sendFile
method (all lowercase -> camelCase). Probably just an oversight in early versions, that got fixed in the latter.
Related Posts:
- Express Render not working return error: No default engine was specified and no extension was provided
- SyntaxError: expected expression, got ‘<'
- How to pass parameters using ui-sref in ui-router to controller
- What does ngf-select do and why is it needed for form validation?
- why angularjs ng-repeat not working
- Unexpected token < in first line of HTML
- Can I use complex HTML with Twitter Bootstrap’s Tooltip?
- How can a Discord bot create a hyperlink in a Discord message in an embed or in general? [closed]
- How to get all place details from a Place Details Request using Google Places API Web Service?
- SyntaxError: Unexpected token o in JSON at position 1
- How do I check whether a checkbox is checked in jQuery?
- SyntaxError: Unexpected token o in JSON at position 1
- (Google Map API) Geocode was not successful for the following reason: REQUEST_DENIED
- Client on Node.js: Uncaught ReferenceError: require is not defined
- How can a Discord bot create a hyperlink in a Discord message in an embed or in general?
- Getting a UnhandledPromiseRejectionWarning when testing using mocha/chai
- Error: Can’t set headers after they are sent to the client
- Express error – TypeError: Router.use() requires middleware function but got a Object
- Reactjs – Form input validation
- Check if checkbox is checked with jQuery
- Heroku: “No default language could be detected for this app” error thrown for node app
- How can I get the data-id attribute?
- How to resolve the C:\fakepath?
- ReferenceError: fetch is not defined
- AngularJS- Login and Authentication in each route and controller
- SyntaxError: Adjacent JSX elements must be wrapped in an enclosing tag
- TypeError: Cannot read property ‘then’ of undefined
- Invalid shorthand property initializer
- nodejs – error self signed certificate in certificate chain
- Adding options to select with javascript
- How can I mock an ES6 module import using Jest?
- How does the data-toggle attribute work? (What’s its API?)
- How to read xml file contents in jQuery and display in html elements?
- How do I scroll to an element using JavaScript?
- Programmatically change the src of an img tag
- TypeError: Router.use() requires middleware function but got a Object
- SyntaxError: Cannot use import statement outside a module
- How to determine the installed webpack version
- Error: Failed to execute ‘appendChild’ on ‘Node’: parameter 1 is not of type ‘Node’
- node.js TypeError: path must be absolute or specify root to res.sendFile [failed to parse JSON]
- Failed to compile. Module not found: Can’t resolve ‘react-router-dom’
- Angular JS Uncaught Error: [$injector:modulerr]
- MissingSchemaError: Schema hasn’t been registered for model “User”
- Cannot find module ‘internal/fs’ after upgrading to node 7
- How can I select an element by name with jQuery?
- Full-screen iframe with a height of 100%
- How can I group data with an Angular filter?
- jQuery disable/enable submit button
- node-request – Getting error “SSL23_GET_SERVER_HELLO:unknown protocol”
- Parse an HTML string with JS
- Shortest way to print current year in a website
- OnChange event handler for radio button (INPUT type=”radio”) doesn’t work as one value
- Partial render in HTML/JavaScript
- Error: Cannot find module html
- Is it possible to append to innerHTML without destroying descendants’ event listeners?
- TypeError: res.status is not a function
- Showing an image from an array of images – Javascript
- Set value to currency in
- HTML Entity Decode
- How to connect signalR from angularJs
- Array Mapping in AngularJs
- How can I copy to clipboard in HTML5 without using flash?
- HTML5 rich-text inside textarea
- Maximum call stack size exceeded on npm install
- AngularJS errors: Blocked loading resource from url not allowed by $sceDelegate policy
- How to scroll an HTML page to a given anchor
- How do you completely remove Ionic and Cordova installation from mac?
- How do I check if a cookie exists?
- Error: listen EACCES 0.0.0.0:80 OSx Node.js
- how to call a onclick function in tag?
- How do I refresh a DIV content?
- Failed to execute ‘postMessage’ on ‘DOMWindow’: https://www.youtube.com !== http://localhost:9000
- JavaScript button onclick not working
- jQuery sort elements using data id
- What counts as CPU Intensive tasks (eg. sorting, searching etc?)
- How to redirect to another page using AngularJS?
- HTML make text clickable without making it a hyperlink
- events.js: 141 throw er; // Unhandled ‘error’ event
- getContext is not a function
- JavaScript code to stop form submission
- Getting HTML form values
- Change an image with onclick()
- How to run a function when the page is loaded?
- Disabled href tag
- Why is this simple AngularJS ng-show not working?
- Creating Accordion Table with Bootstrap
- Creating Multiple Modals on a Single Page
- Closing Bootstrap modal onclick
- window.location() not working, not opening page
- How to clear the canvas for redrawing
- Default text on input
- Calling a JavaScript function in another js file
- Javascript, viewing [object HTMLInputElement]
- $http.get(…).success is not a function
- Why onbeforeunload event is not firing
- Is there a way to create interfaces in ES6 / Node 4?
- Contact Form 7 – Give each checkbox a class?
- Do I just put the html in a page when enqueueng or do I also have to reference js file from the html page [closed]
- how to do open a link in a open window from menu bar? [closed]
- Sending GravityForms to custom HTML