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 trialBegana Choi
Courses Plus Student 13,126 Pointsis there anyone the solution doesn't work?
I was very confused that why my code doesn't work and finally I'm checking the solution but my code is just the same as he wrote. is there anyone like me? there is error message on localhost:3000
/Users/beganachoi/Documents/code/tech-degree-6/practice/views/index.pug:8 6| 7| //- 1. Use Pug's each
iterator to render recipe markup for each recipe object > 8| each recipe in recipes 9| //- 2. Render the href
attribute using the recipe ID. For example: '/recipes/1' 10| a(href=/recipes/${recipe.id}
) 11| //- 3. Dynamically display the recipe name Cannot read property 'length' of undefined
TypeError: /Users/beganachoi/Documents/code/tech-degree-6/practice/views/index.pug:8
6|
7| //- 1. Use Pug's each
iterator to render recipe markup for each recipe object
8| each recipe in recipes 9| //- 2. Render the
href
attribute using the recipe ID. For example: '/recipes/1' 10| a(href=/recipes/${recipe.id}
) 11| //- 3. Dynamically display the recipe name
Cannot read property 'length' of undefined at eval (eval at wrap (/Users/beganachoi/Documents/code/tech-degree-6/practice/node_modules/pug-runtime/wrap.js:6:10), <anonymous>:26:32) at eval (eval at wrap (/Users/beganachoi/Documents/code/tech-degree-6/practice/node_modules/pug-runtime/wrap.js:6:10), <anonymous>:53:4) at template (eval at wrap (/Users/beganachoi/Documents/code/tech-degree-6/practice/node_modules/pug-runtime/wrap.js:6:10), <anonymous>:55:72) at Object.exports.renderFile (/Users/beganachoi/Documents/code/tech-degree-6/practice/node_modules/pug/lib/index.js:427:38) at Object.exports.renderFile (/Users/beganachoi/Documents/code/tech-degree-6/practice/node_modules/pug/lib/index.js:417:21) at View.exports.__express as engine at View.render (/Users/beganachoi/Documents/code/tech-degree-6/practice/node_modules/express/lib/view.js:135:8) at tryRender (/Users/beganachoi/Documents/code/tech-degree-6/practice/node_modules/express/lib/application.js:640:10) at Function.render (/Users/beganachoi/Documents/code/tech-degree-6/practice/node_modules/express/lib/application.js:592:3) at ServerResponse.render (/Users/beganachoi/Documents/code/tech-degree-6/practice/node_modules/express/lib/response.js:1008:7)
Mark Riddell
15,970 PointsI'm having the same problem. Tried killing and resetting the server, but to no avail.
3 Answers
Gábor Szalai
17,881 PointsInstall nodemon like in the original course or restart the server after each modification. (npm install -g nodemon)
Joseph Lander
Full Stack JavaScript Techdegree Graduate 27,765 PointsI had the same issue and solved it just like Connor Nally found. I had not finished writing my code completely but had saved the file, which ran the server and showed the same error of 'recipes' being undefined. 'Correct the error'/complete my work, close and restart and we were ok. Quite annoyed as 30 minutes of research trying to figure out why I was wrong, had to give up and watch Guil's solution. See I have the same at this point and it still doesn't work.
To me, software development seems to have a lot of issues solved with the phrase "Have you tried turning it off and on again?"
Carlos Machado
Full Stack JavaScript Techdegree Graduate 16,525 PointsI got an error 304 on the console and google said that it might be the cache on my browser. I cleaned it and it worked, then I had the problem again and restarting the server solved it again
Connor Nally
22,401 PointsConnor Nally
22,401 PointsI had the exact same problem, stupidly trying to work out what was wrong. I restarted the server and it worked. Don't ask me how or why...