简体   繁体   English

无法使用react-native init创建项目

[英]can't create project using react-native init

I am getting this error again and again when creating a new project using react-native init. 使用react-native init创建新项目时,我一次又一次收到此错误。 I reinstalled react-native cli and tried again but no luck. 我重新安装了react-native cli并再次尝试,但是没有运气。 Can someone please tell me is there anything I can do? 有人可以告诉我我能做些什么吗?

在此处输入图片说明

I have following versions installed react-native-cli: 2.0.1 react-native: 0.56.0 node: 10.6.0 npm: 6.1.0 我安装了以下版本react-native-cli:2.0.1 react-native:0.56.0节点:10.6.0 npm:6.1.0

This error is may be because of react native version React native 0.56 此错误可能是由于react native版本React native 0.56

Here is the link about the discussion of this issue React native 0.56.* - "Unexpected identifier" 这是关于此问题的讨论的链接React native 0.56。*-“意外标识符”

So they suggest us to downgrade the version of react-native React Native Version List 所以他们建议我们降级react-native React Native版本列表的版本

So open the file of your project named as package.json 因此,打开名为package.json项目文件

inside it you can find react-native": "0.56.4" replace this version with react-native": "0.55.4" or what ever the version you want 在其中可以找到react-native": "0.56.4"将此版本替换为react-native": "0.55.4"或所需的任何版本

then save the file 然后保存文件

go to the terminal or power sell 去终端或电力销售

rich to the your project directory and run the command npm-install 进入您的项目目录并运行命令npm-install

after installation check the version of react-native by running the command react-native --version and make sure that version is which you changed in package.json 安装后检查的版本react-native运行命令react-native --version ,并确保该版本是你改变package.json

restart your project and you are ready to go without this error 重新启动您的项目,您就可以准备好了,没有出现此错误

This problem can be resolve in one line code nothing more 只需一行代码即可解决此问题

$ react-native init [projectName] --version react-native@0.55.4

what this does is that you explicitly tell that you want your project to be created with this specify version 它的作用是您明确告诉您要使用此指定版本创建项目

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM