Using Node.js in MODX Cloud
What is Node.js®?
npm, its command-line package installer tool that is akin to
You can use
npm to include function-specific bits of well-tested code from other developers in your own projects. This can be front-end things like Angular.js, or back-end toolkits to help you develop projects more quickly like Grunt, Bower and other automation or build tools.
Installing Node.js on your Cloud
Node.js is available going to he Add-ons tab of your Cloud and locating Compass/Sass/Node.js from the Software section and clicking to toggle to trigger activation. This is a semi-manual process at this time and the team will enable it as quickly as possible during business hours.
Using Node.js in MODX Cloud
Node.js is available in MODX Cloud to aid in site development or augment a website’s functionality. Using Node requires that you interact with the MODX Cloud via SSH.
Bower—Web sites are made of lots of things — frameworks, libraries, assets, and utilities. Bower manages all these things for you.
Grunt—The less work you have to do when performing repetitive tasks like minification, compilation, unit testing, linting, etc, the easier your job becomes. After you’ve configured it through a Gruntfile, a task runner can do most of that mundane work for you—and your team—with basically zero effort.
Gulp—A streaming build system that accomplishes many of the same things as Grunt, albeit in a very different way.
Example: Install Gulp in MODX Cloud
Install Node.js. Go he Add-ons tab of your Cloud and locating Compass/Sass/Node.js from the Software section and clicking to toggle to trigger activation.
The MODX Cloud support team will install the necessary libraries into your MODX Cloud instance and send you a notification once installed.
Connect to your instance using SSH, then install Gulp:
npm install -g gulp
This will put the
gulpcommand in your system path, allowing it to be run from any directory.
Now you need to install a sample task file for your project. Grunt by itself doesn’t do anything. An example Gruntfile demo that includes many helpful utilities can be used as follows:
git clone https://github.com/Omeryl/cloud-gulp-test
When that completes, enter:
cd cloud-gulp-test && npm install
Now, start Gulp:
When Gulp is running, you can see it in action by executing the following command from the CLI:
cp -R www/index.html dist /www/
In this demo, the following things are used, as indicated in the
gulpfile.js, including installing dependencies automagically for you as indicated in the
Here are some additional resources to help you learn more about leveraging Node.js in MODX Cloud:
- “What is npm?” explainer video on Youtube
- The “Gulp – The basics” screencast on Youtube
- “Getting Started with Gulp” by Travis Maynard
Node.js is a trademark of Joyent, Inc. and is used with its permission. We are not endorsed by or affiliated with Joyent.