How do I require Stylus in Spine using CommonJS?

260 Views Asked by At

I would like to use the javascript API Stylus offers in my Spine app.

To do this, I have to require Stylus.

Because Stylus is a dependency of Hem I tried requiring it in the index.coffee:

Stylus    ?= require('stylus')

But this resulted in an error:

uncaught exception: module Stylus not found

Then I tried including Stylus independently in the package.json

{
  "name": "Blank",
  "version": "0.0.1",
  "engines": {
     "node": "0.6.x",
     "npm":  "1.0.x"
  },
  "dependencies": { 
    "serveup": "~0.0.2",
    "hem": "~0.1.7",
    "stylus" : "~0.22.6",
    "es5-shimify": "~0.0.1",
    "json2ify": "~0.0.1",
    "jqueryify": "~0.0.1",
    "spine": "~1.0.5",
    "spine.mobile": "~1.0.0",
    "gfx": "~0.0.4"
  }
}

And in my slug.json

{
  "dependencies": [
    "es5-shimify", 
    "json2ify", 
    "jqueryify", 
    "spine",
    "spine/lib/local",
    "spine/lib/ajax",
    "spine/lib/relation",
    "spine/lib/route",
    "spine/lib/tmpl",
    "spine/lib/manager",
    "stylus"
  ],
  "libs": []
}

But this resulted in an error in the server log:

Unhandled error!

How can I require Stylus and make use of its API in Spine?

1

There are 1 best solutions below

2
On

I feel like you forgot to run npm install after adding the stylus dependency into your app package.json.