我有一个困难的时间为超级分类账系统建立一个客户端网络接口。据我所知,我必须对Node脚本执行以下导入操作:
import { Gateway } from 'fabric-network';导入在Node脚本上工作,但是当与React一起构建时抛出和出错。看上去像是一个错误在一个叫做“填充”的东西上。我不熟悉这个术语。呈现中出现的错误如下:
ERROR in ./node_modules/@grpc/grpc-js/build/src/call-stream.js 24:14-30
Module not found: Error: Can't resolve 'http2' in '/home/tylr/Documents/energychain-login/node_modules/@grpc/grpc-js/build/src'
ERROR in ./node_modules/@grpc/grpc-js/build/src/call-stream.js 26:11-24
Module not found: Error: Can't resolve 'os' in '/home/tylr/Documents/energychain-login/node_modules/@grpc/grpc-js/build/src'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "os": require.resolve("os-browserify/browser") }'
- install 'os-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "os": false }
ERROR in ./node_modules/@grpc/grpc-js/build/src/call.js 26:17-34
Module not found: Error: Can't resolve 'stream' in '/home/tylr/Documents/energychain-login/node_modules/@grpc/grpc-js/build/src'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
- install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "stream": false }
ERROR in ./node_modules/@grpc/grpc-js/build/src/channel-credentials.js 24:14-28
Module not found: Error: Can't resolve 'tls' in '/home/tylr/Documents/energychain-login/node_modules/@grpc/grpc-js/build/src'
ERROR in ./node_modules/@grpc/grpc-js/build/src/channelz.js 24:14-28
Module not found: Error: Can't resolve 'net' in '/home/tylr/Documents/energychain-login/node_modules/@grpc/grpc-js/build/src'
ERROR in ./node_modules/@grpc/grpc-js/build/src/compression-filter.js 24:13-28
Module not found: Error: Can't resolve 'zlib' in '/home/tylr/Documents/energychain-login/node_modules/@grpc/grpc-js/build/src'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "zlib": require.resolve("browserify-zlib") }'
- install 'browserify-zlib'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "zlib": false }
ERROR in ./node_modules/@grpc/grpc-js/build/src/http_proxy.js 30:13-28
Module not found: Error: Can't resolve 'http' in '/home/tylr/Documents/energychain-login/node_modules/@grpc/grpc-js/build/src'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
- install 'stream-http'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "http": false }
ERROR in ./node_modules/@grpc/grpc-js/build/src/http_proxy.js 32:12-26
Module not found: Error: Can't resolve 'tls' in '/home/tylr/Documents/energychain-login/node_modules/@grpc/grpc-js/build/src'
ERROR in ./node_modules/@grpc/grpc-js/build/src/http_proxy.js 40:14-28
Module not found: Error: Can't resolve 'url' in '/home/tylr/Documents/energychain-login/node_modules/@grpc/grpc-js/build/src'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
- install 'url'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "url": false }
ERROR in ./node_modules/@grpc/grpc-js/build/src/resolver-dns.js 25:12-26
Module not found: Error: Can't resolve 'dns' in '/home/tylr/Documents/energychain-login/node_modules/@grpc/grpc-js/build/src'
ERROR in ./node_modules/@grpc/grpc-js/build/src/resolver-dns.js 27:13-28
Module not found: Error: Can't resolve 'util' in '/home/tylr/Documents/energychain-login/node_modules/@grpc/grpc-js/build/src'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'
- install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "util": false }
ERROR in ./node_modules/@grpc/grpc-js/build/src/resolver-dns.js 41:14-28
Module not found: Error: Can't resolve 'net' in '/home/tylr/Documents/energychain-login/node_modules/@grpc/grpc-js/build/src'
ERROR in ./node_modules/@grpc/grpc-js/build/src/resolver-ip.js 23:14-28
Module not found: Error: Can't resolve 'net' in '/home/tylr/Documents/energychain-login/node_modules/@grpc/grpc-js/build/src'
ERROR in ./node_modules/@grpc/grpc-js/build/src/server-call.js 26:14-30
Module not found: Error: Can't resolve 'http2' in '/home/tylr/Documents/energychain-login/node_modules/@grpc/grpc-js/build/src'
ERROR in ./node_modules/@grpc/grpc-js/build/src/server-call.js 28:17-34
Module not found: Error: Can't resolve 'stream' in '/home/tylr/Documents/energychain-login/node_modules/@grpc/grpc-js/build/src'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
- install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "stream": false }
ERROR in ./node_modules/@grpc/grpc-js/build/src/server-call.js 30:13-28
Module not found: Error: Can't resolve 'zlib' in '/home/tylr/Documents/energychain-login/node_modules/@grpc/grpc-js/build/src'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "zlib": require.resolve("browserify-zlib") }'
- install 'browserify-zlib'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "zlib": false }任何帮助都将不胜感激。更好的是,我希望能够作为一个客户端建立一个连接,从网络端到网关。并从数据库中检索客户端密钥,并将其设置为ENV变量,至少在这个初步开发阶段是这样的。
这是正确的方法,还是网关应该连接到REST,然后web端连接到它。
希望这里有足够的信息来说明我所面临的问题,我将积极地检查这个线程,并期待得到回应。
发布于 2022-07-28 20:52:26
fabric没有经过测试,也没有任何设计可以直接在浏览器中使用,所以我并不奇怪您是否有问题试图让它工作。我认为您最好运行一个rest服务器来执行fabric交互,并让您的web应用程序通过它进行交互。这里有一个rest服务器在fabric示例回购中可能会有所帮助。
https://github.com/hyperledger/fabric-samples/tree/main/asset-transfer-basic/rest-api-typescript
https://stackoverflow.com/questions/73158243
复制相似问题