I've just tried using JPM for the first time, and I can't get anything to work.
My index.js file looks like this:
const actionButton = require('sdk/ui/button/action');
const TAG = "Addon Scratchpad / Index ";
console.log(TAG+'in index.js');
var button = actionButton.ActionButton({
id: "my-button",
label: "my button",
icon: {
"16": "./tool-scratchpad-16.png",
"32": "./tool-scratchpad-32.png"
},
onClick: function() {
debugger;
console.log(TAG+'button clicked');
}
});
The Folder structure is standard: index.js
and package.json
files and a data
folder with the button png
assets.
jpm run
results in the browser opening. But no button is generated, there are no errors in the terminal or console, the addon debugger claims "This page has no sources."
jpm test
results in no tests being run and no errors thrown.
jpm run --debugger
doesn't launch the debugger.
There were no errors during JPM installation (I uninstalled and reinstalled globally to check).
index.js is in the root of the directory, which isn't what I'm used to, but this is apparently normal:
your main file is "index.js", and it is found directly in your add-on's root.
If I unpackage the xpi it looks normal. If I install it by dragging to Firefox the same issues persist.
I'm stumped. Any ideas why I can't get it to work?
jpm 0.0.25 has some important changes in it that will only work with Firefox 38 ( the current nightly version ).
The quick fix for now is to pin your jpm version at 0.0.23:
npm install -g jpm@0.0.23
I logged this jpm issue: https://github.com/mozilla/jpm/issues/261
来源:https://stackoverflow.com/questions/28374278/jpm-not-working