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 trial

JavaScript Build a Simple Dynamic Site with Node.js Creating a Simple Server in Node.js Preparing & Planning

Error running example_profile.js

I am following the build a dynamic website with node. When attempting to run the example_profile.js file I am getting this error.

I am using intellij IDEA I have install the node.js plugin and added the node global library to the project.

I am getting this error

/Users/caleb.king/Documents/coding practice/Node Applications/First Node Dynamic Site/example_profile.js:3
var studentProfile = new Profile("chalkers");
                     ^
TypeError: object is not a function
    at Object.<anonymous> (/Users/caleb.king/Documents/coding practice/Node Applications/First Node Dynamic Site/example_profile.js:3:22)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

2 Answers

Nicholas Olsen
seal-mask
.a{fill-rule:evenodd;}techdegree
Nicholas Olsen
Front End Web Development Techdegree Student 19,342 Points

I just finished that course. I had a similar issue, but not with example_profile.js. Here are some things I would look for if I were you.

  • Make sure profile.js is in the same directory.
  • At the top of your file make sure you have var Profile = require('./profile'); Make sure it is "var Profile," not "var profile"

Good look with this NodeJS is super exciting! :)

Nicholas Olsen Was the course informative and understandable to you?

Chris Skinner
Chris Skinner
3,807 Points

Also make sure you have the following at the bottom of your Profile function (outside)

module.exports = Profile;