Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialChip Carnes
20,961 PointsNo such file or directory, open './views/header.html'
When working on the filesystem part of this video, I'm getting this error once I try to run the server from a localhost.
fs.js:549 return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode); ^
Error: ENOENT: no such file or directory, open './views/header.html' at Error (native) at Object.fs.openSync (fs.js:549:18) at Object.fs.readFileSync (fs.js:397:15) at Object.view (/Users/chipcarnes/Documents/Programming Courses/Treehouse Courses/Build a dynamic site with Node/renderer.js:5:27) at Object.home (/Users/chipcarnes/Documents/Programming Courses/Treehouse Courses/Build a dynamic site with Node/router.js:9:14) at Server.<anonymous> (/Users/chipcarnes/Documents/Programming Courses/Treehouse Courses/Build a dynamic site with Node/app.js:8:10) at emitTwo (events.js:87:13) at Server.emit (events.js:172:7) at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:521:12) at HTTPParser.parserOnHeadersComplete (_http_common.js:88:23)
Here's my code from the renderer.js file:
var fs = require('fs');
function view(templateName, values, response) { //read from template files var fileContents = fs.readFileSync('./views/' + templateName + '.html'); //insert values in to the Content //write out the contents to the response response.write(fileContents); }
module.exports.view = view;
Anyone know what's going on here or what to do about the server error?
Krysttian Duncan
2,373 PointsKrysttian Duncan
2,373 PointsIf someone comes back to this, remember you remove the \n from the routes.js file from the renderer.view line. thats what did it for me atleast!