admin管理员组文章数量:1403500
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';
本文标签: javascriptGitHubjs does not provide an export named 39default39Stack Overflow
版权声明:本文标题:javascript - GitHub.js does not provide an export named 'default' - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744379298a2603420.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论