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 trialBlake Foster
10,184 Pointsargv not printing out username array.
When I call console.dir(process.argv); It does not return the array of users. It only returns the first two indexes.
glasscheck
7,302 Pointsfrom Node.js Documentation
"The process.argv property returns an array containing the command line arguments passed when the Node.js process was launched."
https://nodejs.org/docs/latest/api/process.html#process_process_argv
pause video at 1.08 he inputs "node app.js", that is in fact the process.argv array
" node" and "app.js"
so process.argv === ["node","app.js"]
the username array is code written with app.js, process.argv are the arguments you input when you run your script
Jonathan Mitten
Courses Plus Student 11,197 PointsIn order to show the usernames with argv, you need to pass those usernames into the console along with the app's filename, so:
node app.js chalkers jonathanmitten alenaholligan
The node.js docs for process.argv show that the first two argv values are [0] : process.execPath and [1] the path to the JavaScript file being executed. Those will always be those two values. Any additional arguments passed when executing the JS script via node will be the additional command line arguments.
Blake Foster
10,184 PointsSolved. I wasn't passing the arguments. I just had a complete mental breakdown for some reason, haha. Thanks guys.
Butler Fuqua
5,706 PointsI was having the same issue. Thanks for posting! I guess I overlooked that he did that.
Jonathan Mitten
Courses Plus Student 11,197 PointsJonathan Mitten
Courses Plus Student 11,197 PointsHi Blake,
Please post your code so we can see better what the issue might be.