Problems with the tumblr.js API installation

49 views
Skip to first unread message

rpet...@googlemail.com

unread,
Nov 17, 2015, 8:10:55 AM11/17/15
to mozilla-labs-jetpack
Hi Guys
I am trying to write myself a small firefox plugin to interact with the blogging site tumblr.com
I've managed to create a firefox plugin that gets the info I need and now I want to post it.
The problem is that while I have used npm to install the js API I cannot get it running.

This is the main error I am getting:

Module `fs` is not found at resource://gre/modules/commonjs/fs.js

From what I have seen so far ''fs' is a node module but not one included with jpm.
After doing an npm install for 'js' I am still getting the same error.

I have tried doing this in both the plugin main directory and the tumblr.js directory to add it to its own node_modules folder.

Any help with this would be well received.

Rob

Adrian Aichner

unread,
Nov 17, 2015, 8:25:34 AM11/17/15
to mozilla-labs-jetpack
See
https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/cfx_to_jpm#Requiring_local_modules

I guess you are not specifying a relative path starting in ./ or ../ which is required for jpm tooling.

rpet...@googlemail.com

unread,
Nov 17, 2015, 9:31:33 AM11/17/15
to mozilla-labs-jetpack
Thanks for that! It worked but has presented a further issue-

Is there a way of writing require paths relative to the plugin directory?
Otherwise it seems I will either have to have the same module in multiple locations or have long paths to get back up to the top level.

Rob

Adrian Aichner

unread,
Nov 17, 2015, 9:41:10 AM11/17/15
to mozilla-la...@googlegroups.com


On 17.11.2015 15:31, rpet...@googlemail.com wrote:
Thanks for that! It worked but has presented a further issue-

Is there a way of writing require paths relative to the plugin directory?

What was the change you made to make it work?

It should still be a relative path.

What you are writing is a Firefox Add-on SDK add-on (or jetpack for short).

Plugin is something completely different.

--
You received this message because you are subscribed to the Google Groups "mozilla-labs-jetpack" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mozilla-labs-jet...@googlegroups.com.
To post to this group, send email to mozilla-la...@googlegroups.com.
Visit this group at http://groups.google.com/group/mozilla-labs-jetpack.
For more options, visit https://groups.google.com/d/optout.

rpet...@googlemail.com

unread,
Nov 17, 2015, 10:04:56 AM11/17/15
to mozilla-labs-jetpack
I changed
var fs = require('fs');
to
var fs = require('../node_modules/fs');

After installing the fs module in the tumblr module.
However there are a bunch of other dependencies that I am now having to install modules for and correct the require paths as I go.

Either I am doing something wrong or there is a substantial amount of changes I need to make to the dependency structure of the tumblr.js module compatible with the JPM.

Rob
To unsubscribe from this group and stop receiving emails from it, send an email to mozilla-labs-jetpack+unsub...@googlegroups.com.

Adrian Aichner

unread,
Nov 17, 2015, 12:33:22 PM11/17/15
to mozilla-la...@googlegroups.com
Ah, perhaps it's the --save argument that will help you:

https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Using_third-party_modules_%28jpm%29#Details

Then you should drop the relative path prefix again.

Let me know when this works out for you.
To unsubscribe from this group and stop receiving emails from it, send an email to mozilla-labs-jet...@googlegroups.com.

rpet...@googlemail.com

unread,
Nov 17, 2015, 12:56:40 PM11/17/15
to mozilla-labs-jetpack
The --save argument simply adds the module to the dependency list. It makes no difference to the required path needed for the require() field.

Rob

Vincent Barreau

unread,
Nov 23, 2015, 3:56:21 AM11/23/15
to mozilla-labs-jetpack
Ok,

Maybe I am a bit late, and it is not a sharp answer, but ..

Although JPM is using npm and nodejs to build add-ons, and that we can use npm module in the addon, it doesn't mean that it will work.
As the add-on will run in firefox, then it won't have access to nodejs... this mean that all the modules that refer to a nodejs functionality won't work. And this is hard to know if any package do...
In your case, the module you want to use is obviously using some nodejs functionality, and it would be hard to track and replace them all.
I guess your best option would be to check the code of the tumblr.com module, and rewritte it with firefox add-on functionality (replacing nodejs ones, by firefox ones). Like dealing with files with FileUtils.jsm, and dealing with request with the high-level API request, or just XMLHttpRequest.

Or am I totally wrong and JPM add-on have access to nodejs functionality (like 'fs' and 'http')?? But I really doubt it.

Then again, I might be a bit outside the scope of your question...

Vincent
Reply all
Reply to author
Forward
0 new messages