首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >同构-git TypeError()克隆:无法读取未定义的属性“”bind“”

同构-git TypeError()克隆:无法读取未定义的属性“”bind“”
EN

Stack Overflow用户
提问于 2020-08-03 10:42:24
回答 1查看 112关注 0票数 0

我想在Kintone上使用带有BrowserFS的同构git(它不支持模块导入)。

我不控制脚本标记,但这就是它们被包含在结果页面中的方式:

代码语言:javascript
复制
<script src="https://unpkg.com/isomorphic-git@1.7.4"></script>
<script src="https://unpkg.com/browserfs"></script>

然后,我初始化BrowserFS以使用浏览器的IndexedDB作为它的文件系统:

代码语言:javascript
复制
(new Promise((resolve,reject)=> {
  BrowserFS.getFileSystem({
    fs: "IndexedDB",
    options: {}
  }, function(error,fs) {
    if (error) {
      BrowserFS.configure({
        fs: "IndexedDB",
        options: {}
      }, function(error) {
        if (error) {
          reject(error)
        }
        const fs = BrowserFS.BFSRequire("fs")
        BrowserFS.BFSRequire("path")
        resolve(fs)
      })
    }
    resolve(BrowserFS.initialize(fs))
  })
})).then(fs => {
  ...

最后,我对同构-git模块使用了dynamic import:

代码语言:javascript
复制
  return import('https://unpkg.com/isomorphic-git@1.7.4/http/web/index.js').then(http => {
    window.http = http
    return true
  })
}).then(response => {
  ...

当我尝试运行git克隆命令时...

代码语言:javascript
复制
  return git.clone({
    fs,
    http,
    dir:stagingRoot,
    corsProxy: 'https://cors.isomorphic-git.org',
    url: repositoryURL.getValue(),
    ref: branch.getValue(),
    onAuth: url => {
      const auth = {
        username: username.getValue(),
        password: password.getValue(),
      }
      return auth
    },
    singleBranch: true,
    depth: 100
  })
}).then(response => {
  ...

我得到以下TypeError:

代码语言:javascript
复制
Uncaught (in promise) TypeError: Cannot read property 'bind' of undefined
    at new u (isomorphic-git@1.7.4:formatted:157)
    at Module.<anonymous> (isomorphic-git@1.7.4:formatted:13793)
    at Generator.next (<anonymous>)
    at Qt (isomorphic-git@1.7.4:formatted:13757)
    at a (isomorphic-git@1.7.4:formatted:13771)
    at isomorphic-git@1.7.4:formatted:13776
    at new Promise (<anonymous>)
at Module.<anonymous> (isomorphic-git@1.7.4:formatted:13768)
at Module.re (isomorphic-git@1.7.4:formatted:13821)
at Module.ee (isomorphic-git@1.7.4:formatted:13782)

知道它是从哪里来的吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-08-05 10:15:16

这是一个简单的脚本标签导入排序问题。正确的顺序是:

代码语言:javascript
复制
<script src="https://unpkg.com/browserfs"></script>
<script src="https://unpkg.com/isomorphic-git@1.7.4"></script>

我在使用BrowserFS时遇到了其他问题,所以我最终又回到了同构-git提供的闪电文件系统...

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63223044

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档