9

can i use mootools on the serverside with nodejs?

If so, can someone give an example?

Andreas Köberle
  • 106,652
  • 57
  • 273
  • 297
Tyler Gillies
  • 1,857
  • 4
  • 22
  • 31

3 Answers3

14

Out of date: http://davidwalsh.name/mootools-nodejs

The correct way now is via the npm, which is actually upto date.

npm install mootools --save

using it:

require("mootools");
// globals exported and types shimmed
var foo = new Class({}); // etc

things not exported: Element protos, Fx, Slick (and parser), Request (XHR), Swiff etc - if it touches the DOM, it won't be there.

Still, given the JS implementation under nodejs is pretty awesome anyway, shimming is not required (other than some sugar methods) and for Class, you can use prime - npm install prime - see https://github.com/mootools/prime/

example on RequireBin: http://requirebin.com/?gist=5957603

Dimitar Christoff
  • 26,147
  • 8
  • 50
  • 69
5

Just to update this. If you have NPM installed you can just run:

npm install mootools

Then at the top of your node file just include:

require('mootools')

Source: https://github.com/vsviridov/mootools-node

Adam Meyer
  • 1,505
  • 1
  • 19
  • 28
3

From http://mootools.net/download

This is a customized MooTools build without any component relative to browsers. Includes Class, Core and Native Extensions. It's specifically made for server-side environments such as node.js, v8cgi, Rhino or SpiderMonkey.

http://mootools.net/download/get/mootools-core-1.4.5-server.js

kilianc
  • 7,397
  • 3
  • 26
  • 37