如何修复nativescript中的“ TypeError:process.hrtime不是函数”?

时间:2019-11-01 04:33:21

标签: nativescript aws-amplify nativescript-angular

我正在使用aws-amplify构建本机脚本(+ Angular)应用程序。特别是在使用aws-amplify的S3 Storage API时,出现以下错误:

AWSS3Provider - get signed url error TypeError: process.hrtime is not a function. (In 'process.hrtime()', 'process.hrtime' is undefined)

我正在使用以下polyfills

(window as any).global = window;
(window as any).process = {
  env: { DEBUG: undefined },
};

在我的代码中,我检查进程是否未定义。

        if(typeof process !== 'undefined') {
        Storage.get('fileassets/asset.txt')
            .then(result => alert(result))
            .catch(err => alert(err));
        } else {
            alert("process is undefined");
        }

没有引发警报,但是似乎本地代码S3Provider依赖process.hrtime,在非nativescript环境中无法解决

我希望aws-amplify API能成功执行,因为它无法控制,避免调用process.hrtime。

0 个答案:

没有答案