Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Node.js Basics (2014) Building a Command Line Application Handling Errors in Node

Brian Fong
Brian Fong
Courses Plus Student 17,935 Points

Arrow functions not supported in Node challenge when they've been supported in the latest version of Node?

Node is supposed to support arrow functions since it's based off of V8. My guess is it's turned off in the install settings for the treehouse console?

The code works if I replace it with a normal anonymous function and omit the arrow function.

It just doesn't make sense when you put a workshop talking about arrow functions and not have them supported for whatever upcoming lessons in the Full Stack Javascript track. Notice how const works but the treehouse code checker says I didn't define error in the arrow function.

var http = require("http");

const request = http.get("http://teamtreehouse.com/chalkers.json", function(response){

request.on('error', (error) => {

1 Answer

If I create a new Workspace and use the 'Node.js' template as a starting point, it runs Node v6.2.2 which supports arrow functions: http://w.trhou.se/8fmlgab5fg

I expect that some of the courses have been built on older Workspace templates running older versions of Node. Technically you could upgrade and use arrow functions, but with a lot of things JavaScript and the web, version management can be tricky, as you want a large majority of users to be able to use your code/app, but don't want to miss out on newer features.

Another good example is the React course, where they aren't using the ES6/ES2015 versions of creating components, despite Facebook recommending it.

I guess another reason is so that they can concentrate on teaching you whatever the course is on, rather than also trying to simultaneously teach ES2015.