我正在尝试在上设置我的React Native环境
Macbook Pro M1X
,关注
https://reactnative.dev/docs/next/environment-setup
并且仍然面临问题。
在中创建新项目后
网络风暴
我收到此错误:
TypeError: cli.init is not a function
at run (/Users/mymac1/.npm/_npx/10e3bde211213596/node_modules/react-native-cli/index.js:302:7)
at createProject (/Users/mymac1/.npm/_npx/10e3bde211213596/node_modules/react-native-cli/index.js:249:3)
at /Users/mymac1/.npm/_npx/10e3bde211213596/node_modules/react-native-cli/index.js:217:7
at /Users/mymac1/.npm/_npx/10e3bde211213596/node_modules/prompt/lib/prompt.js:316:32
at /Users/mymac1/.npm/_npx/10e3bde211213596/node_modules/async/lib/async.js:142:25
at assembler (/Users/mymac1/.npm/_npx/10e3bde211213596/node_modules/prompt/lib/prompt.js:313:9)
at /Users/mymac1/.npm/_npx/10e3bde211213596/node_modules/prompt/lib/prompt.js:322:32
at /Users/mymac1/.npm/_npx/10e3bde211213596/node_modules/prompt/lib/prompt.js:597:5
at Interface.onLine (/Users/mymac1/.npm/_npx/10e3bde211213596/node_modules/read/lib/read.js:111:5)
at Interface.emit (node:events:512:28)
我遵循并安装了:
-
节点&守望者
-
Xcode+在平台中集成命令行工具+已安装iOS模拟器
-
安装了Ruby gem(CocoaPods),后来根据用户建议将版本更改为2.7.6
尝试在终端中启动React Native项目:(在线建议版本/与最新版本的问题相同)
npx react-native init mnkn --version 0.68.2
我得到了这个错误:
error Error: Looks like your iOS environment is not properly set. Please go to https://reactnative.dev/docs/next/environment-setup and follow the React Native CLI QuickStart guide for macOS and iOS.
Error: Error: Looks like your iOS environment is not properly set. Please go to https://reactnative.dev/docs/next/environment-setup and follow the React Native CLI
在终端使用“纱线”使用“纱线添加博览会”解决了这个问题,然后
npx-react原生init-mnkn--版本0.68.2
工作(在终端)。
在WebStorm中也出现了同样的错误(即使是Yarn)。
我刚开始学习JavaScript和React Native,我的背景只有Python和C。
在网上找不到帮助,所以我很感激你的帮助。