Viewers: in countries Watching now:
Here's my solution to the challenge. I now have a flight repl, I can create flight objects, and they're automatically displayed in my console. I can also use the triggerArrive and triggerDepart functions. So let's take a look at how I did this. In index.js, I'm starting out with a hash bang, this command locates Node for us, so that we can run our script. Next, I require the repl module, and I also require the local flight module that we've been working with. Then, I create a prompt, based off the repl module.
Finally, I assign the flight function into the context of the prompt. Let's also take a look at package.json. I named this project flight, so that flight is the name of the command that I type. Then I also added index.js as the property for bin. When all of this was in place, I went to terminal, and I went to the path of the project. Then I used npm link to install the command. I'm going to start the command back up again. There's one pit fall that you want to avoid when you're creating objects with this flight module.
If I just call flight and don't pass an argument in, it's going to give an error. This function is expecting exactly one argument, so even if you pass in a blank object, it'll still work. So that's how you can create a repl, and make it available as a Command Line tool.
Find answers to the most frequently asked questions about Node.js Essential Training .
Here are the FAQs that matched your search "" :
Sorry, there are no matches for your search "" —to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.