Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
@google cloud/logging能否用于Ionic4/Angular8/Firebase客户端应用程序?如何修复模块导入错误_Angular_Firebase_Google Cloud Logging - Fatal编程技术网

@google cloud/logging能否用于Ionic4/Angular8/Firebase客户端应用程序?如何修复模块导入错误

@google cloud/logging能否用于Ionic4/Angular8/Firebase客户端应用程序?如何修复模块导入错误,angular,firebase,google-cloud-logging,Angular,Firebase,Google Cloud Logging,我想在应用程序中使用nodejs日志记录,使用离子4、Angular 8和Firebase将日志写入StackDriver 在应用程序根目录中,我执行以下操作: npm安装@google云/日志 转到@googlecloud/logging/build/proto/logging.d.ts,并添加以下导入语句:import{Long}from“protobufjs” 在@googlecloud/logging/build/proto/logging.config.d.ts中执行同样的操作 构建爱

我想在应用程序中使用nodejs日志记录,使用离子4、Angular 8和Firebase将日志写入StackDriver

在应用程序根目录中,我执行以下操作:

  • npm安装@google云/日志
  • 转到@googlecloud/logging/build/proto/logging.d.ts,并添加以下导入语句:
    import{Long}from“protobufjs”
  • 在@googlecloud/logging/build/proto/logging.config.d.ts中执行同样的操作
  • 构建爱奥尼亚应用程序
  • 然而,我从许多不同的核心节点模块中得到了一个未发现模块错误列表:加密、child_进程、fs、os、net、path、http、http2、stream、tls和zlib

    错误消息如下:

    错误 ./node_modules/google gax/build/src/operationclientbrowser.js Module 未找到:错误:无法解析中的“/operations\u client\u config” “/home/pam/strata1/strata_forms_app/node_modules/google gax/build/src” 错误 ./node_modules/@google cloud/common/node_modules/google auth library/build/src/auth/googleauth.js 未找到模块:错误:无法解析中的“子进程” “/home/pam/strata1/strata_forms_app/node_modules/@google cloud/common/node_modules/google auth library/build/src/auth” 错误 ./node_modules/@google cloud/logging/node_modules/google auth library/build/src/auth/googleauth.js 未找到模块:错误:无法解析中的“子进程” “/home/pam/strata1/strata_forms_app/node_modules/@google cloud/logging/node_modules/google auth library/build/src/auth” 错误 ./node_modules/@google cloud/common/node_modules/google auth library/build/src/crypto/node/crypto.js 未找到模块:错误:无法解析中的“加密” “/home/pam/strata1/strata_forms_app/node_modules/@google cloud/logging/node_modules/google auth library/build/src/crypto/node”中出现错误 ./node_modules/@opencensus/propagation stackdriver/build/src/stackdriver-format.js 未找到模块:错误:无法解析中的“加密” 中的“/home/pam/strata1/strata_forms_app/node_modules/@opencensus/propagation stackdriver/build/src”错误 ./node_modules/@opencensus/propagation stackdriver/build/src/v1.js

    我刚开始配置webpack,但我尝试将webpack.config.js文件添加到
    @google cloud/logging/build/src
    以及
    /src
    ,其中包含以下配置更改:

    module.exports = {
        //...
        node: {
          console: false,
          global: true,
          process: true,
          __filename: 'mock',
          __dirname: 'mock',
          Buffer: true,
          setImmediate: true,
          child_process: 'empty',
          crypto: 'empty',
          fs: 'empty',
          os: 'empty',
          net: 'empty',
          path: 'empty',
          http: 'empty',
          http2: 'empty',
          stream: 'empty',
          tls: 'empty',
          zlib: 'empty',
        }
      };
    
    鉴于此库被描述为StackDriver node.js客户端库,我希望它能在Ionic4+Angular8+Firebase应用程序中工作

      - Node.js version: 11.10.0
      - npm version: 6.7.0
      - `@google-cloud/logging` version: 5.2.2
      - AngularCLI: 8.2.3
      - typescript: 3.5.3
      - webpack 4.39.2
    

    正如您在GitHub[1]中收到的回复所述:

    “我们正在努力使使用带有Webpack的库成为可能,但这可能需要更多的时间。原因是此库使用gRPC(通过HTTP/2发送协议缓冲区),无法轻松地进行网页打包。在这项工作正在进行时,您可以尝试使用我们不太复杂的库(它通过HTTP/1发送纯JSON,因此可以进行网页打包)。或者,在服务器端处理日志调用。”

    谷歌Api的团队

    我将分享Github中提供的答案,以帮助其他开发人员解决类似问题


    [1]

    这个问题可能已经在这里得到了回答:Harif,谢谢,但是你提到的信息帖子不再相关了-它可能在1年9个月前是真的,但在最新的@google cloud/logging版本5.2.2中,节点模块类型脚本声明文件在build/proto中提供。这是我从Git上的库维护人员那里得到的响应枢纽供参考: