如何修改项目目录结构
来源:1-2 课程导学
Chouee
2022-11-11
默认的项目结构是这样的:RN工程作为一个大项目管理。
现在我想改成这样:RN、iOS、安卓的工程分别管理。
调整了一下目录结构,但是可能RN测的一些脚本路径也需要调整,导致pod install失败。
现在pod install报错如下:
[!] Invalid `Podfile` file: [!] /usr/local/bin/node -e try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}
node:internal/modules/cjs/loader:998
throw err;
^
Error: Cannot find module 'react-native/cli'
Require stack:
- /Users/xunlei/Documents/react_native_work/tdmnft/[eval]
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at [eval]:1:87
at Script.runInThisContext (node:vm:129:12)
at Object.runInThisContext (node:vm:313:38)
at node:internal/process/execution:79:19
at [eval]-wrapper:6:22
at evalScript (node:internal/process/execution:78:60) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/Users/xxx/Documents/react_native_work/tdmnft/[eval]' ]
}
Node.js v18.12.1
.
# from /Users/xxx/Documents/react_native_work/tdmnft/Podfile:15
# -------------------------------------------
#
> config = use_native_modules!
#
# -------------------------------------------
求教!
require_relative已经调整过了,完整podfile如下:
require_relative '../tdmnft_rn/node_modules/react-native/scripts/react_native_pods'
require_relative '../tdmnft_rn/node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '13.0'
install! 'cocoapods', :deterministic_uuids => false
target 'TDMNFT' do
use_frameworks! :linkage => :static
config = use_native_modules!
# Flags change depending on the env values.
flags = get_default_flags()
use_react_native!(
:path => config[:reactNativePath],
# Hermes is now enabled by default. Disable by setting this flag to false.
# Upcoming versions of React Native may rely on get_default_flags(), but
# we make it explicit here to aid in the React Native upgrade process.
:hermes_enabled => true,
:fabric_enabled => flags[:fabric_enabled],
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
# :flipper_configuration => FlipperConfiguration.enabled,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
end
post_install do |installer|
react_native_post_install(
installer,
# Set `mac_catalyst_enabled` to `true` in order to apply patches
# necessary for Mac Catalyst builds
:mac_catalyst_enabled => false
)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
写回答
1回答
-
CrazyCodeBoy
2022-11-13
应该还是路径不对。
tdmnft_rn是你的js目录吗,改成你的js目录试试看呢
00