Angular 仅在生产模式下使用 exif-js 无法正常工作

Angular with exif-js only on production mode not work correctly

当我在我的项目上制作 ng 服务 时,它工作得很好。但是当我 运行 ng build --prod --base-href 然后一些与 exif-js 相关的问题会出现。

main-es2015.4f373a513488bb1e69c9.js:40745 ERROR ReferenceError: n is not defined
    at getStringFromDB (main-es2015.4f373a513488bb1e69c9.js:126856)
    at readEXIFData (main-es2015.4f373a513488bb1e69c9.js:126863)
    at findEXIFinJPEG (main-es2015.4f373a513488bb1e69c9.js:126564)
    at handleBinaryFile (main-es2015.4f373a513488bb1e69c9.js:126485)
    at getImageData (main-es2015.4f373a513488bb1e69c9.js:126501)
    at Function.push../node_modules/exif-js/exif.js.EXIF.getData (main-es2015.4f373a513488bb1e69c9.js:127098)
    at ImagesLoadingService.loadExif (main-es2015.4f373a513488bb1e69c9.js:153715)
    at HTMLImageElement.img.onload [as __zone_symbol__ON_PROPERTYload] (main-es2015.4f373a513488bb1e69c9.js:153689)
    at HTMLImageElement.wrapFn (polyfills-es2015.c96fb5427ba53ad92441.js:1201)
    at ZoneDelegate.invokeTask (polyfills-es2015.c96fb5427ba53ad92441.js:403)

我知道错误原因是某些变量未定义,但为什么在 ng 服务 上它工作正常?

已解决

我在 exif.js 文件中发现问题:

    function getStringFromDB(buffer, start, length) {
        var outstr = "";
        for (let n = start; n < start+length; n++) { // I add let before n variable and now it's work just fine on prod build
            outstr += String.fromCharCode(buffer.getUint8(n));
        }
        return outstr;
    }

我在 ng build --prod --base-href --optimization=false 中构建项目以找到问题所在。在 Firefox 上,我得到 不同的错误描述 ,所以我找不到代码的具体位置。只有在 Chrome 上,我才能获得更具体的信息,才能解决我的问题。我希望其他人也能有所帮助:)

我在 exif.js 文件中发现问题:

    function getStringFromDB(buffer, start, length) {
        var outstr = "";
        for (let n = start; n < start+length; n++) { // I add let before n variable and now it's work just fine on prod build
            outstr += String.fromCharCode(buffer.getUint8(n));
        }
        return outstr;
    }

我在 ng build --prod --base-href --optimization=false 中构建项目以找到问题所在。在 Firefox 上,我得到 不同的错误描述 ,所以我找不到具体的代码位置。只有在 Chrome 上,我才能获得更具体的信息,才能解决我的问题。我希望其他人也能有所帮助:)