【问题标题】:Uncaught ReferenceError: exports is not defined at geotiff.js:3未捕获的 ReferenceError:未在 geotiff.js:3 中定义导出
【发布时间】:2021-07-16 20:44:12
【问题描述】:

我正在尝试在 angular 6.1.0typescript 2.9.2 中使用 geotiff 库。

我是用它安装的

npm i geotiff

但我在浏览器控制台中收到以下错误:

未捕获的 ReferenceError:未定义导出 在 geotiff.js:3

搜索此错误后,我遇到了很多答案。我尝试更改我的tsconfig.json 文件。

module 更改为es5es6none。没用。

target 更改为es5es6。没用。

打开allowJs。没用。

我该如何解决这个错误?

【问题讨论】:

    标签: javascript angular typescript


    【解决方案1】:

    我没有收到您提到的错误,但是库本身内部的某些导入肯定存在问题。 在我的 package.json 中包含此配置后

     "browser": {
        "fs": false,
        "http": false,
        "https": false
      }
    

    像这样导入它

    import GeoTiff, { fromUrl, fromUrls, fromArrayBuffer, fromBlob } from 'geotiff';
    

    在 app-component.ts 中

    export class AppComponent implements OnInit{
      ngOnInit(): void {
        fromUrls("someUrl")
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2018-02-20
      • 1970-01-01
      • 2019-09-07
      • 2018-01-21
      • 2019-02-28
      • 1970-01-01
      • 1970-01-01
      • 2021-02-28
      • 1970-01-01
      相关资源
      最近更新 更多