我按照以下链接开始使用react-native
我试图创建没有expo的本机应用程序,所以按照文档,我遵循以下命令
npm install -g react-native-cli
react-native init AwesomeProject
Run Code Online (Sandbox Code Playgroud)
运行android命令后
react-native run-android
Run Code Online (Sandbox Code Playgroud)
它给我以下模拟器错误
所以我用启动命令来运行Metro服务器
react-native start
Run Code Online (Sandbox Code Playgroud)
这个命令给了我控制台另一个错误
reactjs react-native react-native-android react-native-cli metro-bundler
升级到 RN 0.59.4 并成功构建后 - 人们可能会在 Metro Bunler 中遇到以下错误:
react native Cannot find module 'metro/src/reactNative Transformer
反应本机 0.61
我试图找出我在 XCode 或 iPhone 中哪里破坏了某些东西。几天前一切正常 - 我按了运行 -> 构建成功 -> 一切都通过 wifi 运行(热重载)。
但是今天当我按 Run - Build 成功但没有启动应用程序。重复运行后,应用程序正在启动,但没有连接到 Metro Builder。
我尝试在另一个办公室使用相同的组合。在那里一切正常。
任何 Android 设备上的应用程序都可以完美启动并连接到 Metro Builder。所有模拟器(包括通过 XCode)都工作正常。同样的无线网络。
XCode 输出:
2020-01-30 01:20:57.299821+0200 TestApp[417:22121] Task <6DD1500D-484C-4290-9543-30284F360671>.<1> finished with error [-1001] Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSUnderlyingError=0x280250060 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=http://192.168.1.70:8081/status, NSErrorFailingURLKey=http://192.168.1.70:8081/status, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out.}
2020-01-30 01:20:57.337180+0200 TestApp[417:22123] Task <6DD1500D-484C-4290-9543-30284F360671>.<1> HTTP load failed, 0/0 bytes (error code: -999 [1:89])
2020-01-30 01:20:57.367 [info][tid:main][RCTRootView.m:293] Running …Run Code Online (Sandbox Code Playgroud) 我有一个包含组件路径的 path.json 文件
// path.json
{
"main": "./login/index.js",
"paths": [
{
"name": "login",
"path": "./login/index.js",
"image": ""
}
]
}
Run Code Online (Sandbox Code Playgroud)
我想在 react native 中动态加载'./login/index.js'文件并呈现这个特定文件
我目前的实施
const MyComponent = createLazyContainer(() => {
const componentPath = PathJson.main; // ./login/index.js
return import(`${componentPath}`); //import error here @ line 7
});
export default MyComponent;
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
第 7 行的无效调用:import("" + componentPath)
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 …Run Code Online (Sandbox Code Playgroud) 每当我们尝试在 XCode 上构建 RN 应用程序时,Metro Bundler都会运行一个新实例,我想知道 bundleJs 存储在哪里。
询问的原因是,我想知道以下命令是否不必要
react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios
Run Code Online (Sandbox Code Playgroud)
尝试发布 RN 应用程序时采取的步骤:
1 - 运行上述命令手动生成 JSBundle 文件
2 - 在 XCode 上存档项目
3 - 验证
4 - 上传
简而言之,如果步骤 2 -Archive流程也会启动 Metro Bundler 的新实例,那么步骤 1 似乎是多余的?还是我实际上拿错了图片?
我正在运行 npx 脚本来在 VS Code 集成终端中构建,但 Metro Bundler 在新的 cmd/bash 终端中运行。如何在VS Code集成终端中运行它?
我不知道如何更好地描述它。我正在做 react-native 项目,发生了一些事情,由于某种原因我不能再运行它了。我收到一些奇怪的消息,比如无法克隆某些功能。
error: src/requests/TimeoutRequest.ts: function (path) {
return fn.call(state, path, state);
} could not be cloned.
Run Code Online (Sandbox Code Playgroud)
或者:
error: src/sensors/GPS.ts: Program(path) {
importAll = path.scope.generateUid("$$_IMPORT_ALL");
importDefault = path.scope.gen...<omitted>... } could not be cloned.
Run Code Online (Sandbox Code Playgroud)
所有版本:
npm version: 7.10.0
"react": "^16.11.0",
"react-native": "^0.62.2",
dev:
"@babel/core": "^7.13.15",
"@babel/runtime": "^7.13.10",
"babel-jest": "^24.9.0",
"babel-plugin-root-import": "^6.6.0",
"metro-react-native-babel-preset": "^0.57.0",
"react-test-renderer": "16.9.0"
Run Code Online (Sandbox Code Playgroud)
如果我注释掉这个函数。我在另一个中出错,依此类推。中间发生了什么:我更新了 npm 版本。然后我在下载一些库时遇到了一些问题,我不得不rm -rf node_modules && npm install.
我试过的:
谷歌搜索,一般。找不到任何可行的解决方案。发现它可能是 babel 问题,但它可能完全错误,我不知道
npm start --reset-cache
删除缓存文件夹、守望者的东西等等
npm install --legacy-peer-deps
克隆项目并在另一个文件夹中执行所有操作
恢复或删除 package-lock.json 和 yarn.lock。安装或不安装它们 …
我不知道为什么会这样显示,问题发生在 Bundler.js 上,错误指向这一行。
TransformFile(filePath, transformOptions) {
var _this3 = this;
return _asyncToGenerator(function*() {
// We need to be sure that the DependencyGraph has been initialized.
// TODO: Remove this ugly hack!
yield _this3._depGraphPromise;
return _this3._transformer.transformFile(filePath, transformOptions);
})();
Run Code Online (Sandbox Code Playgroud)
补充一点可能很重要,我是通过 nvm 安装节点的。
谢谢你!
metro-bundler ×10
react-native ×10
reactjs ×2
babeljs ×1
bundler ×1
ecmascript-6 ×1
javascript ×1
node-modules ×1
node.js ×1
npm ×1
xcode ×1