To be able to generate an MLJS application using the generator you will need two things installed. The first is Yeoman. The second is the generator. Go ahead and take a moment to install them.
$ npm install -g yo$ npm install -g generator-mljs
There, that's better, isn't it? You'll also need MarkLogic installed. Fortunately, this is not painful.
Download MarkLogic from the faithful and trustworthy MarkLogic servers. Follow the simple instructions to get MarkLogic installed.
To get started you'll need a content database and a REST database. Depending on your setup, an administrator may have already created one for you or you have admin rights and can create one yourself. Fortunately, if you do need to create one, the generator will create a simple setup to get you started.
You can skip this if there's already a server and db. When you type:
$ yo mljs
You are prompted with a series of questions. The first asks you to select your setup options. Choose "Create a content db and a rest service" from the menu.
When you type
$ yo mljs
You will select "Nothing to do - REST service and content db exist."
|hostname||Your MarkLogic server hostname or IP address|
|admin username||Required if you need to create a new REST service, optional otherwise|
|admin password||Required if you need to create a new REST service, otherwise optional|
|service name||The name you want to give your service so you can identify it.|
|service port||The port the REST service should use|
|content db name||The name of the content db to use or create.|
_-----_| ||--(o)--| .--------------------------.`---------´ | Welcome to Yeoman, |( _´U`_ ) | ladies and gentlemen! |/___A___\ '__________________________'| ~ |__'.___.'__´ ` |° ´ Y `You're using the fantastic Mljs generator.[?] Select your setup options: Create a content db and a rest service[?] What is your MarkLogic Server hostname? localhost[?] What is your admin username? admin[?] What is your admin password? x8kia30[?] What's Rest Service Name? myotherservice[?] What's the REST Service Port? 9997[?] What's the content database name? (MyDb)
Assuming everything went well, what you have at this point is a functioning Node/Express application with support for MLJS. What you need to determine is how you will use MLJS.
You can use MLJS from your Node (server side) code. In this case you will make calls to the rest service directly from your Node app.
You can also use MLJS from the browser. In this case your Node application is serving content and the queries execute directly against the MarkLogic server from your browser.
This generator currently supports both modes by both loading the NPM module for MLJS and the bower components for MLJS browser widgets.