[Pkg-javascript-devel] Resolving "pure" javascript libraries from NodeJS

Jérémy Lal holisme at gmail.com
Sun Nov 6 22:20:21 UTC 2011


On 06/11/2011 22:17, David Paleino wrote:
> On Sun, 6 Nov 2011 22:03:33 +0100, David Paleino wrote:
> 
>> It seems like the package is asking for "wax", which is a
>> pure-javascript library, to be used from a web browser, even though it is
>> available from npmjs.org. I packaged (correctly, I hope) libjs-wax, but this
>> code horribly fails in Node:
>>
>>> require.resolve('wax/wax.mm.min.js')
>> Error: Cannot find module 'wax/wax.mm.min.js'
>>     at Function._resolveFilename (module.js:326:11)
>>     at Function.resolve (module.js:359:19)
>>     at [object Context]:1:9
>>     at Interface.<anonymous> (repl.js:179:22)
>>     at Interface.emit (events.js:64:17)
>>     at Interface._onLine (readline.js:153:10)
>>     at Interface._line (readline.js:408:8)
>>     at Interface._ttyWrite (readline.js:585:14)
>>     at ReadStream.<anonymous> (readline.js:73:12)
>>     at ReadStream.emit (events.js:81:20)
> 
> # ln -s /usr/share/javascript/wax /usr/lib/nodejs/
> 
> makes it work.
> 
> Obviously it's the worst solution I could think at. And the only one too :)

Reading https://github.com/mapbox/tilemill/blob/master/servers/Route.bones,
they're using require.resolve() to get the path to the javascript assets.
It's a strange way to find files, isn't it ?
Anyway libjs-wax is a browser only library, and is correctly not on node's modules path,
but it has to be somewhere on the local path of your application, so i think you
can fix your problem by simply adding 
usr/share/javascript/wax usr/whatever/path/to/tilemill/wax
to tilemill debian/links

Jérémy.



More information about the Pkg-javascript-devel mailing list