简体   繁体   English

GitHub.js不提供名为'default'的导出

[英]GitHub.js does not provide an export named 'default'

I am trying to use GitHub.js on a Chrome/Firefox extension and I have some issues. 我正在尝试在Chrome / Firefox扩展程序上使用GitHub.js,但遇到一些问题。

Uncaught SyntaxError: The requested module '/static/GitHub.bundle.js' does not provide an export named 'default' 未捕获的SyntaxError:所请求的模块'/static/GitHub.bundle.js'不提供名为'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. 99%的javascript的作者都认为基础知识是理所当然的,但是我不了解它们,或者有一个我看不到的细微问题/错误。

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: 和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". 请注意,我必须使用.js或得到“找不到文件”。

Library: https://github.com/github-tools/github 库: https : //github.com/github-tools/github

The solution was to remove the include and add the .js file and its depencies on the html file. 解决方案是删除包含文件,并将.js文件及其依赖关系添加到html文件中。 Note that it's not really clear if you read github.js' site. 请注意,如果您阅读github.js的站点,还不清楚。

<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';

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 index.js' 不提供名为 'default' 的导出 - index.js' does not provide an export named 'default' 请求的模块“./react.js”不提供名为“默认”的导出 - The requested module './react.js' does not provide an export named 'default' 未捕获的语法错误:请求的模块“/@modules/vue.js”未提供名为“默认”的导出 - Uncaught SyntaxError: The requested module '/@modules/vue.js' does not provide an export named 'default' 请求的模块“./server/controller/controller.js”不提供名为“default”的导出 - The requested module './server/controller/controller.js' does not provide an export named 'default' 请求的模块不通过快速路由提供名为 default 的导出 - The requested module does not provide an export named default via express routing SyntaxError:请求的模块“sqlite”不提供名为“default”的导出 - SyntaxError: The requested module 'sqlite' does not provide an export named 'default' 未捕获的语法错误:请求的模块“https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js”未提供名为“default”的导出 - Uncaught SyntaxError: The requested module 'https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js' does not provide an export named 'default' “请求的模块 &#39;./login.js&#39; 不提供名为 &#39;loggedIn&#39; 的导出 - "The requested module './login.js' does not provide an export named 'loggedIn' 不提供名为“ BrowserQRCodeReader”的导出 - does not provide an export named 'BrowserQRCodeReader' TypeScript 不提供默认导出 - TypeScript does not provide default export
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM