Wiki Page: Node.js Runtime

  • Thread starter Thread starter David Berger
  • Start date Start date
Status
Not open for further replies.
D

David Berger

Guest
Welcome to Modulus! This guide will walk you through all the necessary steps to deploy a Node.js application on the Modulus platform. VIDEO 1. WRITE SOMETHING MODULUS DEMO APP If you would like to exercise the platform and don’t have an application ready yet, grab the Modulus demo application. git clone git://github.com/onmodulus/modulus-demo.git SETUP YOUR APPLICATION More about application setup can be found in the application guidelines . Use the environment variable PORT. app.listen(process.env.PORT) Specify your dependencies in the package.json file. { "name": "my-application", "version": "0.0.1", "description": "My application description.", "main": "app.js", "dependencies" : { "express" : "2.5.x", "ejs" : "0.8.x" } } Specify the main file in your package.json. { "name": "my-application", "version": "0.0.1", "description": "My application description.", "main": "path/to/custom_main.js" , "dependencies" : { "express" : "2.5.x", "ejs" : "0.8.x" } } Specify the version of Node your application requires. { "name": "my-application", "version": "0.0.1", "description": "My application description.", "main": "path/to/custom_main.js", "dependencies" : { "express" : "2.5.x", "ejs" : "0.8.x" }, "engines" : { "node": "0.10.x" } } 2. INSTALL THE MODULUS CLI (OPTIONAL) In order to install the Modulus CLI, you must first install Node.js. You can find installers for all majors OS’s at nodejs.org . Now that node.js is installed you may proceed to install the modulus CLI. In most cases, the the command line interface (CLI) is going to be a more convenient way to deploy an application. The CLI is optional and every task it can preform can also be performed using the web interface. $ npm install -g modulus 3. LOG IN If you are using the CLI you will need to log in before you can create or deploy a project. Assuming you have already created an account , logging in through the CLI is easy. The Modulus CLI stores authentication information locally (as a token, not actual usernames and passwords), so logins are only required once. $ modulus login Welcome to Modulus [?] Enter your username or email: parker@example.com [?] Enter your password: [✓] Signed in as user spiderman If you created an account using GitHub, you can use the --github (-g) option to log in with your GitHub credentials. Note: Github logins do not work with two-factor authentication enabled. $ modulus login --github Welcome to Modulus [?] Enter your GitHub username or email: pparker [?] Enter your password: [✓] Signed in as user spiderman 4. CREATE PROJECT A project can be created through the user dashboard in the web interface, or through the Modulus CLI. MODULUS CLI Run the project create command. $ modulus project create Welcome to Modulus You are logged in as spiderman [?] Enter a project name: Lizard Locator You can optionally pass in the name of your project to the project create command. $ modulus project create "Lizard Locator" Welcome to Modulus You are logged in as spiderman Creating project Lizard Locator [√] New project Lizard Locator created. WEB INTERFACE When you first log in you will see an empty project list. Click "Create New Project" and type in your project name. 5. DEPLOY MODULUS CLI Run the deploy command. This will zip and deploy your current directory, or the path your provide to the command. $ cd path/to/project $ modulus deploy [?] Are you sure you want to use project Lizard Locator? (yes) Compressing project... 6.6 MB written Uploading project... Upload progress [===================] 100% Deploying Project... Deploying [ = ] [✓] Lizard Locator running at lizard-locator-895.onmodulus.net WEB INTERFACE ZIP YOUR PROJECT DIRECTORY You can use any zip tool of your choice. If you’re on Mac or Linux, here’s a convenient way to zip the contents using the command line. $ cd path/to/project $ zip -r myProject.zip . (Don’t forget the dot at the end) Windows does not provide a zip command by default, but you can zip items through the GUI. UPLOAD THE ZIP FILE Log in to Modulus and enter your project's dashboard by clicking its name in the project list. Locate the Deploy block in the upper-right-hand corner and click the "Browse" button. Select the zip file you just created, then click "Upload". Wait for the deploy dialog to complete. When it's done, your application is live and you will be shown your application's URL. Don't forget to tweet about your first deploy!

Continue reading...
 
Status
Not open for further replies.
Back
Top