当我运行
fastlane
来部署我的应用程序的测试版时。它崩溃并出现与 PhaseScriptExecution
Bundle
65
相关的错误。我发现我可以用 CONFIGURATION=1 ./node_modules/react-native/scripts/react-native-xcode.sh
重新创建错误
该命令在 https://github.com/facebook/metro/blob/v0.71.0/packages/metro/src/node-haste/DependencyGraph.js#L207 崩溃
SHA-1 for file /project/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/node-haste/DependencyGraph/assets/empty-module.js (/project/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/node-haste/DependencyGraph/assets/empty-module.js) is not computed.
Potential causes:
1) You have symlinks in your project - watchman does not follow symlinks.
2) Check `blockList` in your metro.config.js and make sure it isn't excluding the file path.
我不确定发生了什么,但返回到之前的提交或执行
rm -rf node_modules; npm i
并不能解决问题。
我发现 https://github.com/facebook/metro/issues/330#issue-389608574 并尝试了建议的解决方法(
vi node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/node-haste/DependencyGraph.js
),但随后我运行 CONFIGURATION=1 ./node_modules/react-native/scripts/react-native-xcode.sh
并得到:
error Unable to resolve module /project/node_modules/metro-runtime/src/modules/asyncRequire.js from /project/.:
None of these files exist:
* ../project/node_modules/metro-runtime/src/modules/asyncRequire.js(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
* ../project/node_modules/metro-runtime/src/modules/asyncRequire.js/index(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx).
Error: Unable to resolve module /project/node_modules/metro-runtime/src/modules/asyncRequire.js from /project/.:
None of these files exist:
* ../project/node_modules/metro-runtime/src/modules/asyncRequire.js(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
* ../project/node_modules/metro-runtime/src/modules/asyncRequire.js/index(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
at ModuleResolver.resolveDependency (/project/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:107:15)
at DependencyGraph.resolveDependency (/project/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/node-haste/DependencyGraph.js:295:43)
at /project/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/lib/transformHelpers.js:129:24
at Server._resolveRelativePath (/project/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/Server.js:1072:12)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Server.build (/project/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/Server.js:139:31)
at async buildBundleWithConfig (/project/node_modules/@react-native-community/cli-plugin-metro/build/commands/bundle/buildBundle.js:110:20)
at async Command.handleAction (/project/node_modules/@react-native-community/cli/build/index.js:192:9)
info Run CLI with --verbose flag for more details.
我检查了一下,文件存在......
project % cat node_modules/metro-runtime/src/modules/asyncRequire.js
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
"use strict"; // $FlowExpectedError Flow does not know about Metro's require extensions.
const dynamicRequire = require;
module.exports = function(moduleID) {
return Promise.resolve().then(() => dynamicRequire.importAll(moduleID));
};
project %
我不确定下一步应该尝试什么?
PS:
此外,我检查了符号链接,并在 node_modules 中找到了一堆符号链接,但没有找到任何用于节点加速的符号链接。我不明白地铁是如何抱怨节点急速而不是所有其他的。
project % find . -type l -ls | grep -v -E ios.Pods | grep metro
37860573 0 lrwxr-xr-x 1 kevin staff 89 May 28 21:23 ./node_modules/.bin/metro-inspector-proxy -> ../@react-native-community/cli-plugin-metro/node_modules/metro-inspector-proxy/src/cli.js
37860574 0 lrwxr-xr-x 1 kevin staff 87 May 28 21:23 ./node_modules/.bin/metro-symbolicate -> ../@react-native-community/cli-plugin-metro/node_modules/metro-symbolicate/src/index.js
37860607 0 lrwxr-xr-x 1 kevin staff 19 May 28 21:23 ./node_modules/.bin/metro -> ../metro/src/cli.js
37860477 0 lrwxr-xr-x 1 kevin staff 42 May 28 21:23 ./node_modules/metro-transform-worker/node_modules/.bin/parser -> ../../../@babel/parser/bin/babel-parser.js
37860478 0 lrwxr-xr-x 1 kevin staff 25 May 28 21:23 ./node_modules/metro-transform-worker/node_modules/.bin/metro -> ../../../metro/src/cli.js
37860481 0 lrwxr-xr-x 1 kevin staff 28 May 28 21:23 ./node_modules/metro-transform-worker/node_modules/metro-cache/node_modules/.bin/rimraf -> ../../../../../rimraf/bin.js
37860484 0 lrwxr-xr-x 1 kevin staff 39 May 28 21:23 ./node_modules/metro-transform-worker/node_modules/metro-source-map/node_modules/.bin/metro-symbolicate -> ../../../metro-symbolicate/src/index.js
37860440 0 lrwxr-xr-x 1 kevin staff 22 May 28 21:23 ./node_modules/metro-cache/node_modules/.bin/rimraf -> ../../../rimraf/bin.js
37860439 0 lrwxr-xr-x 1 kevin staff 26 May 28 21:23 ./node_modules/metro-cache/node_modules/.bin/mkdirp -> ../../../mkdirp/bin/cmd.js
37860214 0 lrwxr-xr-x 1 kevin staff 19 May 28 21:23 ./node_modules/@react-native-community/cli-plugin-metro/node_modules/.bin/metro -> ../metro/src/cli.js
37860240 0 lrwxr-xr-x 1 kevin staff 51 May 28 21:23 ./node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-transform-worker/node_modules/.bin/parser -> ../../../../../../@babel/parser/bin/babel-parser.js
37860241 0 lrwxr-xr-x 1 kevin staff 25 May 28 21:23 ./node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-transform-worker/node_modules/.bin/metro -> ../../../metro/src/cli.js
37860228 0 lrwxr-xr-x 1 kevin staff 31 May 28 21:23 ./node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-cache/node_modules/.bin/rimraf -> ../../../../../../rimraf/bin.js
37860218 0 lrwxr-xr-x 1 kevin staff 41 May 28 21:23 ./node_modules/@react-native-community/cli-plugin-metro/node_modules/@react-native-community/cli-tools/node_modules/.bin/semver -> ../../../../../../../semver/bin/semver.js
37860217 0 lrwxr-xr-x 1 kevin staff 32 May 28 21:23 ./node_modules/@react-native-community/cli-plugin-metro/node_modules/@react-native-community/cli-tools/node_modules/.bin/mime -> ../../../../../../../mime/cli.js
37860225 0 lrwxr-xr-x 1 kevin staff 31 May 28 21:23 ./node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/node_modules/.bin/rimraf -> ../../../../../../rimraf/bin.js
37860223 0 lrwxr-xr-x 1 kevin staff 41 May 28 21:23 ./node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/node_modules/.bin/metro-inspector-proxy -> ../../../metro-inspector-proxy/src/cli.js
37860224 0 lrwxr-xr-x 1 kevin staff 39 May 28 21:23 ./node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/node_modules/.bin/metro-symbolicate -> ../../../metro-symbolicate/src/index.js
37860221 0 lrwxr-xr-x 1 kevin staff 51 May 28 21:23 ./node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/node_modules/.bin/parser -> ../../../../../../@babel/parser/bin/babel-parser.js
37860222 0 lrwxr-xr-x 1 kevin staff 46 May 28 21:23 ./node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/node_modules/.bin/image-size -> ../../../../../../image-size/bin/image-size.js
37860231 0 lrwxr-xr-x 1 kevin staff 25 May 28 21:23 ./node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-config/node_modules/.bin/metro -> ../../../metro/src/cli.js
37860237 0 lrwxr-xr-x 1 kevin staff 39 May 28 21:23 ./node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-source-map/node_modules/.bin/metro-symbolicate -> ../../../metro-symbolicate/src/index.js
37860234 0 lrwxr-xr-x 1 kevin staff 40 May 28 21:23 ./node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-minify-uglify/node_modules/.bin/uglifyjs -> ../../../../../../uglify-es/bin/uglifyjs
37860266 0 lrwxr-xr-x 1 kevin staff 51 May 28 21:23 ./node_modules/@react-native-community/cli/node_modules/metro-transform-worker/node_modules/.bin/parser -> ../../../../../../@babel/parser/bin/babel-parser.js
37860267 0 lrwxr-xr-x 1 kevin staff 25 May 28 21:23 ./node_modules/@react-native-community/cli/node_modules/metro-transform-worker/node_modules/.bin/metro -> ../../../metro/src/cli.js
37860247 0 lrwxr-xr-x 1 kevin staff 28 May 28 21:23 ./node_modules/@react-native-community/cli/node_modules/@react-native-community/cli-plugin-metro/node_modules/.bin/metro -> ../../../../metro/src/cli.js
37860260 0 lrwxr-xr-x 1 kevin staff 31 May 28 21:23 ./node_modules/@react-native-community/cli/node_modules/metro/node_modules/.bin/rimraf -> ../../../../../../rimraf/bin.js
37860257 0 lrwxr-xr-x 1 kevin staff 41 May 28 21:23 ./node_modules/@react-native-community/cli/node_modules/metro/node_modules/.bin/metro-inspector-proxy -> ../../../metro-inspector-proxy/src/cli.js
37860258 0 lrwxr-xr-x 1 kevin staff 48 May 28 21:23 ./node_modules/@react-native-community/cli/node_modules/metro/node_modules/.bin/metro-symbolicate -> ../../../../../../metro-symbolicate/src/index.js
37860255 0 lrwxr-xr-x 1 kevin staff 51 May 28 21:23 ./node_modules/@react-native-community/cli/node_modules/metro/node_modules/.bin/parser -> ../../../../../../@babel/parser/bin/babel-parser.js
37860256 0 lrwxr-xr-x 1 kevin staff 46 May 28 21:23 ./node_modules/@react-native-community/cli/node_modules/metro/node_modules/.bin/image-size -> ../../../../../../image-size/bin/image-size.js
37860259 0 lrwxr-xr-x 1 kevin staff 35 May 28 21:23 ./node_modules/@react-native-community/cli/node_modules/metro/node_modules/.bin/mkdirp -> ../../../../../../mkdirp/bin/cmd.js
37860263 0 lrwxr-xr-x 1 kevin staff 40 May 28 21:23 ./node_modules/@react-native-community/cli/node_modules/metro-minify-uglify/node_modules/.bin/uglifyjs -> ../../../../../../uglify-es/bin/uglifyjs
37860436 0 lrwxr-xr-x 1 kevin staff 22 May 28 21:23 ./node_modules/metro/node_modules/.bin/rimraf -> ../../../rimraf/bin.js
37860434 0 lrwxr-xr-x 1 kevin staff 41 May 28 21:23 ./node_modules/metro/node_modules/.bin/metro-inspector-proxy -> ../../../metro-inspector-proxy/src/cli.js
37860435 0 lrwxr-xr-x 1 kevin staff 33 May 28 21:23 ./node_modules/metro/node_modules/.bin/metro-symbolicate -> ../metro-symbolicate/src/index.js
37860432 0 lrwxr-xr-x 1 kevin staff 42 May 28 21:23 ./node_modules/metro/node_modules/.bin/parser -> ../../../@babel/parser/bin/babel-parser.js
37860433 0 lrwxr-xr-x 1 kevin staff 37 May 28 21:23 ./node_modules/metro/node_modules/.bin/image-size -> ../../../image-size/bin/image-size.js
37860487 0 lrwxr-xr-x 1 kevin staff 28 May 28 21:23 ./node_modules/metro/node_modules/metro-cache/node_modules/.bin/rimraf -> ../../../../../rimraf/bin.js
37860490 0 lrwxr-xr-x 1 kevin staff 22 May 28 21:23 ./node_modules/metro/node_modules/metro-config/node_modules/.bin/metro -> ../../../../src/cli.js
37860493 0 lrwxr-xr-x 1 kevin staff 39 May 28 21:23 ./node_modules/metro/node_modules/metro-source-map/node_modules/.bin/metro-symbolicate -> ../../../metro-symbolicate/src/index.js
37860466 0 lrwxr-xr-x 1 kevin staff 30 May 28 21:23 ./node_modules/metro-core/node_modules/jest-haste-map/node_modules/.bin/sane -> ../../../../../sane/src/cli.js
37860469 0 lrwxr-xr-x 1 kevin staff 27 May 28 21:23 ./node_modules/metro-core/node_modules/jest-util/node_modules/.bin/is-ci -> ../../../../../is-ci/bin.js
37860442 0 lrwxr-xr-x 1 kevin staff 19 May 28 21:23 ./node_modules/metro-config/node_modules/.bin/metro -> ../metro/src/cli.js
37860462 0 lrwxr-xr-x 1 kevin staff 48 May 28 21:23 ./node_modules/metro-config/node_modules/metro-transform-worker/node_modules/.bin/parser -> ../../../../../@babel/parser/bin/babel-parser.js
37860463 0 lrwxr-xr-x 1 kevin staff 25 May 28 21:23 ./node_modules/metro-config/node_modules/metro-transform-worker/node_modules/.bin/metro -> ../../../metro/src/cli.js
37860456 0 lrwxr-xr-x 1 kevin staff 28 May 28 21:23 ./node_modules/metro-config/node_modules/metro/node_modules/.bin/rimraf -> ../../../../../rimraf/bin.js
37860453 0 lrwxr-xr-x 1 kevin staff 41 May 28 21:23 ./node_modules/metro-config/node_modules/metro/node_modules/.bin/metro-inspector-proxy -> ../../../metro-inspector-proxy/src/cli.js
37860454 0 lrwxr-xr-x 1 kevin staff 45 May 28 21:23 ./node_modules/metro-config/node_modules/metro/node_modules/.bin/metro-symbolicate -> ../../../../../metro-symbolicate/src/index.js
37860451 0 lrwxr-xr-x 1 kevin staff 48 May 28 21:23 ./node_modules/metro-config/node_modules/metro/node_modules/.bin/parser -> ../../../../../@babel/parser/bin/babel-parser.js
37860452 0 lrwxr-xr-x 1 kevin staff 43 May 28 21:23 ./node_modules/metro-config/node_modules/metro/node_modules/.bin/image-size -> ../../../../../image-size/bin/image-size.js
37860455 0 lrwxr-xr-x 1 kevin staff 32 May 28 21:23 ./node_modules/metro-config/node_modules/metro/node_modules/.bin/mkdirp -> ../../../../../mkdirp/bin/cmd.js
37860445 0 lrwxr-xr-x 1 kevin staff 30 May 28 21:23 ./node_modules/metro-config/node_modules/jest-haste-map/node_modules/.bin/sane -> ../../../../../sane/src/cli.js
37860448 0 lrwxr-xr-x 1 kevin staff 27 May 28 21:23 ./node_modules/metro-config/node_modules/jest-util/node_modules/.bin/is-ci -> ../../../../../is-ci/bin.js
37860459 0 lrwxr-xr-x 1 kevin staff 37 May 28 21:23 ./node_modules/metro-config/node_modules/metro-minify-uglify/node_modules/.bin/uglifyjs -> ../../../../../uglify-es/bin/uglifyjs
37860475 0 lrwxr-xr-x 1 kevin staff 39 May 28 21:23 ./node_modules/metro-source-map/node_modules/.bin/metro-symbolicate -> ../../../metro-symbolicate/src/index.js
37860472 0 lrwxr-xr-x 1 kevin staff 31 May 28 21:23 ./node_modules/metro-minify-uglify/node_modules/.bin/uglifyjs -> ../../../uglify-es/bin/uglifyjs
project %
错误消息中的注意事项
error Unable to resolve module /project/node_modules/metro-runtime/src/modules/asyncRequire.js from /project/.:
None of these files exist:
* ../project/node_modules/metro-runtime/src/modules/asyncRequire.js(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
首先列出
/project/...
,然后列出 ../project/...
。请注意开头的 ../
。
实际上我的项目的真实目录是
/Project
。 P 大写。然而,这里的路径是 ../project/...
。我认为那里有一些问题。
无论如何,我刚刚做了
mv Project project
,问题就解决了!
我认为这对于任何创建 React 应用程序项目的人来说可能会派上用场。
Chnage in metro.config.js
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
/**
*/
const path = require('path');
const config = {
resolver: {
extraNodeModules: new Proxy(
{},
{
get: (target, name) => {
return path.join(__dirname, '../../node_modules/@example-app/shared');
},
},
),
},
watchFolders: [path.resolve(__dirname, '../'), path.resolve(__dirname, '../..'),path.resolve(__dirname, '../../node_modules/@example-app/shared')],
};
module.exports = mergeConfig(getDefaultConfig(__dirname), config);