将google-cloud与webpack集成时遇到问题 [英] Getting an issue while integrating google-cloud with webpack

查看:506
本文介绍了将google-cloud与webpack集成时遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将google-cloud npm包与我的反应应用程序集成在一起,并且正在使用firebase。



我遇到的错误 -


警告./~/google-cloud/~/hash-stream-validation/index.js模块
未找到:错误:无法解析'
'/ home / linuxbox / React-Workspace / Kaptify / node_modules / google-cloud / node_modules / hash-stream-validation'中的fast-crc32c'
@ ./~/google-cloud/~/ hash-stream-validation / index.js 5:8-30 @
./~/google-cloud/~/@google-cloud/storage/src/file.js @
./~/ google-cloud/~/@google-cloud/storage/src/index.js @
./~/google-cloud/src/index.js @ ./src/actions/UserStateStore.js @
./app.js @ multi(webpack)-dev-server / client? http://127.0.0.1:3000
webpack / hot / dev-server ./app.js



警告在./~/google-cloud/~/google-auto- auth / index.js 53:13-58
关键依赖关系:请求st依赖项是一个表达式



WARNING in ./~/google-cloud/~/grpc/src/node/src/grpc_extension.js
38 :14-35严重依赖关系:依赖关系的请求是
表达式



警告在./~/google-cloud/~/node-pre- gyp / lib / pre-binding.js 19:22-48
关键依赖关系:依赖关系的请求是表达式



警告在./~/ google-cloud /〜/ node-pre-gyp / lib / util / versioning.js
15:20-67关键依赖关系:依赖关系的请求是
表达式

任何人都可以帮我解决这个问题吗? 看你使用的是webpack,我假设你在后端使用 google-cloud 库。



试试把这个放到你的webpack配置中:

  config = { 
// ...
外部:{
'@ google-cloud / storage':'commonjs @ google-cloud / storage'
},
// ...
}



说明



用于后端的模块并不是真正意图将它们捆绑在一起(参见:带Webpack的后端应用程序)。因此,我们使用webpack的 externals config来排除那些不能很好地处理捆绑的库。运行应用程序时,它们正常情况下来自 node_modules 目录的 require()'

。 >

如果您不想一一指定您的违规模块,请尝试 webpack-node-externals 自动排除所有模块。


I am integrating the google-cloud npm package with my react application and i am using firebase.

Errors i am encountering -

WARNING in ./~/google-cloud/~/hash-stream-validation/index.js Module not found: Error: Can't resolve 'fast-crc32c' in '/home/linuxbox/React-Workspace/Kaptify/node_modules/google-cloud/node_modules/hash-stream-validation' @ ./~/google-cloud/~/hash-stream-validation/index.js 5:8-30 @ ./~/google-cloud/~/@google-cloud/storage/src/file.js @ ./~/google-cloud/~/@google-cloud/storage/src/index.js @ ./~/google-cloud/src/index.js @ ./src/actions/UserStateStore.js @ ./app.js @ multi (webpack)-dev-server/client?http://127.0.0.1:3000 webpack/hot/dev-server ./app.js

WARNING in ./~/google-cloud/~/google-auto-auth/index.js 53:13-58 Critical dependency: the request of a dependency is an expression

WARNING in ./~/google-cloud/~/grpc/src/node/src/grpc_extension.js 38:14-35 Critical dependency: the request of a dependency is an expression

WARNING in ./~/google-cloud/~/node-pre-gyp/lib/pre-binding.js 19:22-48 Critical dependency: the request of a dependency is an expression

WARNING in ./~/google-cloud/~/node-pre-gyp/lib/util/versioning.js 15:20-67 Critical dependency: the request of a dependency is an expression

Can anybody help me to resolve this?

解决方案

I see you're using webpack, and I'm assuming you're using the google-cloud library in the backend.

Try putting this in your webpack config:

config = {
    // ...
    externals: {
        '@google-cloud/storage': 'commonjs @google-cloud/storage'
    },
    // ...
}

Explanation

Modules meant for the backend aren't really made with the intention of them being bundled (see: Backend Apps with Webpack). So we use webpack's externals config to exclude libraries that don't handle that bundling well. When the app is run, they are just require()'ed from the node_modules directory as normal.

If you don't want to specify your offending modules one-by-one, try out webpack-node-externals to automatically exclude all modules.

这篇关于将google-cloud与webpack集成时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆