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 trialjohan suh
4,157 Pointshow to run Js file from console?
I tried typing node filename.js and i get this
```treehouse:~/workspace$ javascript random.js
bash: javascript: command not found
treehouse:~/workspace$ node randomjs
module.js:550
throw err;
^
Error: Cannot find module '/home/treehouse/workspace/randomjs'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3
2 Answers
Steven Parker
231,269 PointsYour file is located in the "js" directory, and the name has a period in it, so the syntax for running it with node would be:'
node js/random.js
But, this script is intended to be run from a browser and not by using node, since it uses "prompt" which is a function found only in a browser.
So the proper way to run this would be to use the "preview" button (looks like an eye) in the upper right of the workspace window.
johan suh
4,157 Pointsgreat Steven thank you!
johan suh
4,157 Pointsjohan suh
4,157 Pointshttps://w.trhou.se/7zak83v2u3