TypeError:cli.init不是React Native的功能
MacBook Air M1芯片中运行NPX React-NIT INIT APPNAME时
TypeError: cli.init is not a function
at run (/opt/homebrew/lib/node_modules/react-native-cli/index.js:302:7)
at createProject (/opt/homebrew/lib/node_modules/react-native-cli/index.js:249:3)
at init (/opt/homebrew/lib/node_modules/react-native-cli/index.js:200:5)
at Object.<anonymous> (/opt/homebrew/lib/node_modules/react-native-cli/index.js:153:7)
at Module._compile (node:internal/modules/cjs/loader:1112:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1166:10)
at Module.load (node:internal/modules/cjs/loader:988:32)
at Module._load (node:internal/modules/cjs/loader:834:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(20)
如果您以前安装了全局React-Native-CLI软件包,请删除它,因为它可能会导致意外问题。 You can run the following command:
or
Follow the Reference: https://reactnative.dev/docs/environment-设置
if you previously installed a global react-native-cli package, please remove it as it may cause unexpected issues. You can run the following command:
or
Follow the Reference: https://reactnative.dev/docs/environment-setup
我尝试了上面提到的所有解决方案,除此之外,它们实际上没有工作(NPX React-Nitation Init ProjectName - Version 0.68.2),
但最后我通过从用户文件夹中删除节点模块来解决问题。
现在运行:-npx react-native@最新init projectname
I tried every solution above mentioned none of them didn't worked actually except this(npx react-native init ProjectName --version 0.68.2)
But finally i fixed my issue by deleting node modules from my user folder .
then now run :- npx react-native@latest init projectname
npx反应本地启动aveyproject-version 0.68.2解决了我的问题
npx react-native init AwesomeProject --version 0.68.2 solved my problem
我不记得我用啤酒安装了它,这就是问题所在,必须从那里删除它,也必须
首先卸载:
下一步,安装:
I didn't remember that I installed it with brew and that was the problem, it must be deleted from there as well
First uninstall:
Next step, install:
使用此命令删除React本地CLI
现在无需它。
React Native具有内置命令行接口,您可以使用该界面来生成一个新项目。
检查 reactnative.dev
remove react native cli using this command
no need for it now as.
React Native has a built-in command line interface, which you can use to generate a new project.
Check reactnative.dev
尝试使用此最新命令。
为我工作!
Try with this latest command.
Worked for me!
安装新的反应局全球
安装新的反应本地全局
,然后再次创建项目
install new react-native global
install new react-native global
and create project again
需要使用以下命令来清洁全局环境:
检查与这些列表中的反应态礼物没有任何关系:
安装新的反应局全局,
然后您可以运行:
Need to clean global environments with following commands:
check that nothing related to react-native presents in these lists:
install new react-native global
then you can run:
如果使用纱线:
第一步:
检查全局安装列表:
:
第三步:
第一步
如果使用NPM:
:
检查全局安装列表:
:
第三步:
再次安装
if you use Yarn:
First Step:
Check the Global installation list:
Second Step:
Third Step:
Install them again
if you use NPM:
First Step:
Check the Global installation list:
Second Step:
Third Step:
Install them again
这就是错误来自新版本0.69.0
您可以使用
npx React-nitation Init ProjectName - Version 0.68.2
,然后升至V 0.69。That is error is from the new version 0.69.0
You can use
npx react-native init ProjectName --version 0.68.2
and then upgrade to v 0.69 later.如果您以前安装了全局react-native-cli软件包,请删除它,因为它可能会引起意外问题:
npm卸载-G react-native-cli @react-native-native-cli @react-native-cli-compontity/cli
react react Antial内置命令行界面,您可以用来生成一个新项目。您可以在不使用NPX上安装所有内容的情况下访问它,该npx用node.js寄出。让我们创建一个名为“ AwesomeProject”的新的React Native项目:
npx React-native@最新init akesteyproject ,
如果您将React Antive集成到现有应用程序中,那么如果您从Expo中“弹出”,则无需或者,如果您将Android支持添加到现有的React Native项目(请参阅与现有应用程序集成)。您也可以使用第三方CLI来启动您的React本机应用程序,例如Ignite CLI。
If you previously installed a global react-native-cli package, please remove it as it may cause unexpected issues:
npm uninstall -g react-native-cli @react-native-community/cli
React Native has a built-in command line interface, which you can use to generate a new project. You can access it without installing anything globally using npx, which ships with Node.js. Let's create a new React Native project called "AwesomeProject":
npx react-native@latest init AwesomeProject
This is not necessary if you are integrating React Native into an existing application, if you "ejected" from Expo, or if you're adding Android support to an existing React Native project (see Integration with Existing Apps). You can also use a third-party CLI to init your React Native app, such as Ignite CLI.
如果您以前安装了全局React-native-CLI软件包,请删除它,因为它可能会引起意外问题:
链接
If you previously installed a global react-native-cli package, please remove it as it may cause unexpected issues:
Link Here
我认为最新的稳定版本为0.68.2,因此在此级别上创建项目,使用下面给出的命令
npx react-nib init project projectName-version 0.68.2
I think latest stable version is 0.68.2, so create project at this level using command given below
npx react-native init ProjectName --version 0.68.2
应运行:
纱线全局列表
或npm全局列表
并卸载了列表中的所有cli at react-nvent in List:
Should run:
yarn global list
ornpm global list
And uninstall all cli's of the react-native in list, after run:
我重新安装了与 - 外部的反应本机,这解决了我的问题
I re-installed react native with --exact and this fixed my problem
在命令提示中,
卸载CLI反应本式全局
代码---&GT; NPM卸载-g反应 - cli
install cli在命令提示中安装CLI
A.代码==&gt; npm install -g react-native-cli,
b.code ==&gt; NPM安装-G反应
最终创建项目,
code ==&gt; npx react-nibative initakeyproject
In command Prompt,
uninstall cli react-native global
code---> npm uninstall -g react-native-cli
Install cli in command prompt
a.code==> npm install -g react-native-cli,
b.code==> npm install -g react-native
Finally create project,
code==>npx react-native init AwesomeProject
do-&gt;
YARN Global删除React-Native-Cli&amp; amp; NPM卸载-g react-native-cli
然后 - &gt;
纱线全局添加 @react-native-community/cli
或者
NPM安装-G react-native-cli
Do->
yarn global remove react-native-cli && npm uninstall -g react-native-cli
Then->
yarn global add @react-native-community/cli
or
npm install -g react-native-cli
我能够通过卸载CLI来清除问题,并且只安装反应,
然后
我正在使用
I was able to clear the issue by uninstalling the cli and only installing react-native
then
I am using
如果您已经安装了全球对本地的反应,请通过以下方式卸载它:
NPM卸载-G react-native-cli
然后通过:
npm install -G react-native-cli
然后您可以通过以下命令创建新项目:
NPX React-native Init&lt; project_name&gt; gt;
If you have already installed react native globally, uninstall it by:
npm uninstall -g react-native-cli
Then install it again by:
npm install -g react-native-cli
Then you can create your new project by the following command:
npx react-native init <project_name>
来自 - &gt; https://reactnative.dev/docs/getting-started-without-a-框架
如果您以前安装了全局react-native-cli软件包,请删除它,因为它可能会引起意外问题:
npm unstall -G react-native-cli @react- react-本地社区/CLI
您可以使用React Native Community CLI来生成一个新项目。让我们创建一个名为“ AwesomeProject”的新React本机项目:
npx @react-native-community/cli @最新init awith awith aviraveproject
FROM -> https://reactnative.dev/docs/getting-started-without-a-framework
If you previously installed a global react-native-cli package, please remove it as it may cause unexpected issues:
npm uninstall -g react-native-cli @react-native-community/cli
You can use React Native Community CLI to generate a new project. Let's create a new React Native project called "AwesomeProject":
npx @react-native-community/cli@latest init AwesomeProject