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 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!