What is the Meteor shell
Starting with Meteor 1.0.2 we have available a console on the server, similar to the console we have available on the client in the browser.
Starting the console is very easy. First we need to be sure that the meteor server is up and running then we just need to open a terminal and write:
The console supports command history and auto-completion which will save us a good amount of typing when using the console.
The console is the perfect place to deal with database problems like queries that don't work as expected or to check and improve the query performance.
Sometimes a server method is called after some complex conditions and simulating those conditions on the browser can be very time-consuming. In the console, you can call the method directly and provide it with your desired params and check its behaviour.
Meteor.call('methodName', param1, param2... paramN)
Another handy use of the console is to call third party APIs. Debugging code that use an external API is not easy but with the console things get really simple. You can call the external API and see the response.
Meteor shell available commands
This is the list of available commands (we have access to this list anytime writing .help):
\> .help .break Terminate current command input and display new prompt .clear Alias for .break .exit Disconnect from server and leave shell .help Show this help information .load Load JS from a file into the REPL session .reload Restart the server and the shell .save Save all evaluated commands in this REPL session to a file
_ reload _After doing some changes to the code calling reload will restart the meteor server and the console so changes you have made to the code are reflected on the console.
_ save _ This is another useful feature. After debugging your application just write save and a file name like:
and all the commands of the current session are saved into a file.
The meteor shell is a powerful utility that will save you a lot of time when you are optimising, debugging or checking your application. Unfortunately, at the time of writing this post it is not yet documented in the official Meteor documentation.