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
- How to make a discord bot create an invite for every server it joins?
- map function for objects (instead of arrays)
- Failed to load resource: the server responded with a status of 404 (Not Found)
- Failed to load resource: the server responded with a status of 404 (Not Found)
- Maximum call stack size exceeded error
- How to properly use jsPDF library
- Can I use complex HTML with Twitter Bootstrap’s Tooltip?
- Start script missing error when running npm start
- Google Chrome Uncaught (in promise) DOMException while playing AUDIO
- How can a Discord bot create a hyperlink in a Discord message in an embed or in general? [closed]
- How to you store data for each discord user in the discord server?
- How to get all place details from a Place Details Request using Google Places API Web Service?
- How to make a word underline in Markdown
- SyntaxError: Unexpected token o in JSON at position 1
- ChartJS beginAtZero, min, max doesn’t work
- How do I check whether a checkbox is checked in jQuery?
- Babel 6 regeneratorRuntime is not defined
- how to fix : ” TypeError: Cannot read property ‘addEventListener’ of null”…?//
- Cannot set property InnerHTML of null [duplicate]
- SyntaxError: Unexpected token o in JSON at position 1
- TypeError: Converting circular structure to JSON in nodejs
- ReferenceError: $ is not defined
- How to fix “Cannot read property ‘addEventListener’ of null” error [duplicate]
- React.js: Set innerHTML vs dangerouslySetInnerHTML
- How do I check whether a checkbox is checked in jQuery?
- Babel 7 – ReferenceError: regeneratorRuntime is not defined
- jQuery document.createElement equivalent?
- How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)
- Getting a UnhandledPromiseRejectionWarning when testing using mocha/chai
- (Google Map API) Geocode was not successful for the following reason: REQUEST_DENIED
- Client on Node.js: Uncaught ReferenceError: require is not defined
- Error: Can’t set headers after they are sent to the client
- How can a Discord bot create a hyperlink in a Discord message in an embed or in general?
- How to make a word underline in Markdown
- Pure JavaScript equivalent of jQuery’s $.ready() – how to call a function when the page/DOM is ready for it [duplicate]
- Getting a UnhandledPromiseRejectionWarning when testing using mocha/chai
- require is not defined? Node.js
- Client on Node.js: Uncaught ReferenceError: require is not defined
- Error: Can’t set headers after they are sent to the client
- How to play audio?
- TypeError: Router.use() requires middleware function but got a Object
- Express error – TypeError: Router.use() requires middleware function but got a Object
- How to play audio?
- Cannot GET / Nodejs Error
- What is NODE_ENV and how to use it in Express?
- Node.js heap out of memory
- How can I scroll to an element using jQuery?
- Reactjs – Form input validation
- jQuery.click() vs onClick
- jQuery Get Selected Option From Dropdown
- Include another HTML file in a HTML file
- await is only valid in async function
- How to set NODE_ENV to production/development in OS X
- await is only valid in async function
- Check if checkbox is checked with jQuery
- Heroku: “No default language could be detected for this app” error thrown for node app
- SyntaxError: Unexpected token o in JSON at position 1
- Heroku: “No default language could be detected for this app” error thrown for node app
- SyntaxError: Unexpected token o in JSON at position 1
- Add swipe left/right to web page, but use default swipe up/down
- How to add jQuery code into HTML Page
- How can I get the data-id attribute?
- TypeError: Router.use() requires middleware function but got a Object
- Check if checkbox is checked with jQuery
- What does “res.render” do, and what does the html file look like?
- How to obtain username from Promise
? - NPM ELIFECYCLE error – using node server.js command
- How to resolve the C:\fakepath?
- What is the meaning of == $0 that is shown in inspect element of google chrome for the selected element [duplicate]
- Node.js – SyntaxError: Unexpected token import
- ReferenceError: fetch is not defined
- AngularJS- Login and Authentication in each route and controller
- ‘react-scripts’ is not recognized as an internal or external command
- After $npm install, Getting Error: Cannot find module ‘../lib/utils/unsupported.js’
- Node.js – SyntaxError: Unexpected token import
- Angular: mat-form-field must contain a MatFormFieldControl
- SyntaxError: Adjacent JSX elements must be wrapped in an enclosing tag
- TypeError: Cannot read property ‘then’ of undefined
- (change) vs (ngModelChange) in angular
- Invalid shorthand property initializer
- nodejs – error self signed certificate in certificate chain
- Bootstrap Dropdown menu is not working
- What’s the source of Error: getaddrinfo EAI_AGAIN?
- How to Create simple drag and Drop in angularjs
- jquery SlideToggle effect in upward direction?
- stop all instances of node.js server
- Working with $scope.$emit and $scope.$on
- Change Background color (css property) using Jquery
- Using Node.js require vs. ES6 import/export
- Failed to load resource: net::ERR_FILE_NOT_FOUND loading json.js
- ReferenceError : window is not defined at object.
Node.js - Why is process.env.NODE_ENV undefined?
- Get class name using jQuery
- Node.js Port 3000 already in use but it actually isn’t?