I am trying to use GitHub.js on a Chrome/Firefox extension and I have some issues.
Uncaught SyntaxError: The requested module '/static/GitHub.bundle.js' does not provide an export named 'default'
I've found a possible solution here but I still doesn't work. The authors of 99% of javascript give for granted that the basics are know, but either I don't know them or there is a subtle issue/bug I don't see.
My code is simple:
<html>
<body id="mybody">
<button id="mybutton" >Click me</button>
<script type="module" src="popup.js"></script>
</body>
</html>
and popup.js:
//import GitHub from './GitHub.bundle.js';
import * as GitHub from './GitHub.bundle.js';
function onWindowLoad() {
}
window.onload = onWindowLoad;
document.getElementById("mybutton").addEventListener("click", clickme);
function clickme() {
var github = new GitHub({
username: 'USER',
password: 'PASS',
auth: 'basic'
});
}
it does stop immediately. it doesn't matter what I have after that. What am I doing wrong? It shouldn't work even as a standalone page.
Note that I have to use .js or I get a "file not found".
Library:
I am trying to use GitHub.js on a Chrome/Firefox extension and I have some issues.
Uncaught SyntaxError: The requested module '/static/GitHub.bundle.js' does not provide an export named 'default'
I've found a possible solution here but I still doesn't work. The authors of 99% of javascript give for granted that the basics are know, but either I don't know them or there is a subtle issue/bug I don't see.
My code is simple:
<html>
<body id="mybody">
<button id="mybutton" >Click me</button>
<script type="module" src="popup.js"></script>
</body>
</html>
and popup.js:
//import GitHub from './GitHub.bundle.js';
import * as GitHub from './GitHub.bundle.js';
function onWindowLoad() {
}
window.onload = onWindowLoad;
document.getElementById("mybutton").addEventListener("click", clickme);
function clickme() {
var github = new GitHub({
username: 'USER',
password: 'PASS',
auth: 'basic'
});
}
it does stop immediately. it doesn't matter what I have after that. What am I doing wrong? It shouldn't work even as a standalone page.
Note that I have to use .js or I get a "file not found".
Library: https://github./github-tools/github
Share Improve this question edited Apr 16, 2019 at 14:27 maugch asked Apr 16, 2019 at 13:42 maugchmaugch 1,3183 gold badges22 silver badges50 bronze badges 2-
1
I don't see any
export
statements in their js package, only mon stuff via require() and friends, so my guess would be their first official example is for something else. Removetype="module"
, add a html script tag for GitHub.bundle.js, remove import statement. Done. – woxxom Commented Apr 16, 2019 at 21:05 - @wOxxOm If you write an answer I'm going to accept it. I also had to add underscore.js – maugch Commented Apr 17, 2019 at 6:49
2 Answers
Reset to default 2The solution was to remove the include and add the .js file and its depencies on the html file. Note that it's not really clear if you read github.js' site.
<html>
<body id="mybody">
<button id="mybutton" >Click me</button>
<script src="GitHub.bundle.min.js"></script>
<script src="underscore-min.js"></script>
<script type="module" src="popup.js"></script>
</body>
</html>
There might be a trick to do so:
Try :
import * as GitHub from '/static/GitHub.bundle.js';
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744379299a4571345.html
评论列表(0条)