Fel*_*too 8 npm react-native woocommerce-rest-api metro-bundler
react-native当我使用 npm 插件库运行时,我的 Metro 捆绑程序中显示以下错误@woocommerce/api。它目前是 woocommerce Rest api 的活跃插件。
我搜索了许多有关stream处理cipher-base. 这不起作用。我还删除了node_modules并再次重新安装。进而,npm start -- --reset-cache。没有什么对我有用。请帮帮我。
error: Error: Unable to resolve module stream from C:\**\node_modules\cipher-base\index.js: stream could not be found within the project.
If you are sure the module exists, try these steps:
1. Clear watchman watches: watchman watch-del-all
2. Delete node_modules and run yarn install
3. Reset Metro's cache: yarn start --reset-cache
4. Remove the cache: rm -rf /tmp/metro-*
1 | var Buffer = require('safe-buffer').Buffer
> 2 | var Transform = require('stream').Transform
| ^
3 | var StringDecoder = require('string_decoder').StringDecoder
4 | var inherits = require('inherits')
Run Code Online (Sandbox Code Playgroud)
Stream 不是由调用它的node_module 安装的。Stream 是 NodeJS 内部的原生模块。https://nodejs.org/api/stream.html
为了使用 Stream,您需要使用垫片。您需要使用https://github.com/juliangruber/stream和 Stream-browserify 的某种组合,这是 Stream 的浏览器兼容版本。
仅仅因为它对浏览器友好,并不意味着它对原生反应友好。React-native 运行 JavaScriptCore,Apple 的 JS 引擎。它只有明确的 JS 属性,而您可能认为是 JS 的其他东西并不存在,因为这些东西是由浏览器 shell 提供的。WebCrypto 丢失。
在获得 Stream 的某些 JS 版本后,您可能需要使用 rn-nodeify,这是一个帮助 React Native 模拟 Node 环境的包。它安装了许多可以模拟 Node 的库,用 JS 渲染。然而,这可能就足够了yarn add stream,也许yarn add events接下来。
| 归档时间: |
|
| 查看次数: |
3098 次 |
| 最近记录: |