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 Introducing the Practice

Steve Frenzel
Steve Frenzel
3,027 Points

Practicing loops: "node" command not working

Hi there,

I've installed Node.js (Mac user) and tried to run the program through Terminal and the build-in Terminal of Visual Studio Code but I'm always getting this error message after entering "node forLoops.js":

internal/modules/cjs/loader.js:583
    throw err;
    ^

Error: Cannot find module '/Users/stevefrenzel/forLoops.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)

Can anyone help?

1 Answer

Hey Steve,

Quick question since I can't see where the files are laid out on your computer. Have you verified that you're in the same directory as forLoops.js? From what I can tell, it looks like your terminal is in your users home folder:

/Users/stevefrenzel/forLoops.js

If you downloaded the project files, the forLoops.js file is probably located somewhere in your Downloads folder.

Let me know if that doesn't fix it! -Brandon

Steve Frenzel
Steve Frenzel
3,027 Points

I moved the file to this folder and it worked! Need to brush up my knowledge about the terminal to figure out how to access a different folder. :-) Thanks a lot!