React native npm start命令在react native中给出错误
突然,昨天当我通过命令“expo start”启动项目时,它没有启动,收到一条消息expo没有安装。因此,我安装了expo cli 现在我输入了命令“expo start”,但是它给出了错误 它打开Metro builder,但因错误而停止React native npm start命令在react native中给出错误,react-native,expo,React Native,Expo,突然,昨天当我通过命令“expo start”启动项目时,它没有启动,收到一条消息expo没有安装。因此,我安装了expo cli 现在我输入了命令“expo start”,但是它给出了错误 它打开Metro builder,但因错误而停止 I have been using /programming react native app since last 2 months. Always it used to work fine , I could code and run the simul
I have been using /programming react native app since last 2 months.
Always it used to work fine , I could code and run the simulator on my iphone . The environment details are as follows:
EXPO --version 3.1.2 , npm -v 6.9.0, node -v12.4.0
这就是依赖关系
Microsoft Windows [Version 10.0.17134.1006]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\Jituni>cd C:\Users\Jituni\bholmentorworld
C:\Users\Jituni\bholmentorworld>expo start
Starting project at C:\Users\Jituni\bholmentorworld
Expo DevTools is running at http://localhost:19002
Opening DevTools in the browser... (press shift-d to disable)
Error: Can't find react-native in package.json dependencies
Error: React Native is not installed. Please run `npm install` in your project directory.
Couldn't start project. Please fix the errors and restart the project.
Set EXPO_DEBUG=true in your env to view the stack trace.
您没有在依赖项中安装react本机
Microsoft Windows [Version 10.0.17134.1006]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\Jituni>cd C:\Users\Jituni\bholmentorworld
C:\Users\Jituni\bholmentorworld>expo start
Starting project at C:\Users\Jituni\bholmentorworld
Expo DevTools is running at http://localhost:19002
Opening DevTools in the browser... (press shift-d to disable)
Error: Can't find react-native in package.json dependencies
Error: React Native is not installed. Please run `npm install` in your project directory.
Couldn't start project. Please fix the errors and restart the project.
Set EXPO_DEBUG=true in your env to view the stack trace.
解决方案
您应该使用expo cli创建新项目
首先运行此命令->expo init projectname
在此步骤中,选择空白项目选择。
然后您可以看到生成的项目
第二步,合并依赖项。然后运行npm安装
或纱线安装
LAST,使用
npm start
或warn start
运行react native项目,请向我提供您的package.json。然后由管理员打开cmd并键入expo--version
。然后给我世博版。@Dragon White{“main”:“node_modules/expo/AppEntry.js”,“scripts”:{“start”:“expo start”,“android”:“expo start--android”,“ios”:“expo start--ios”,“web”:“expo start--web”,“eject”:“expo eject”},“依赖项”:{“eslint”:“^6.2.1”,“expo”:“^33.0.0”,“firebase”:“^6.4.0”,“react”:“16.8.3”,“react dom”:“^16.8.6”,“react native手势处理程序”:“^1.2.2”,“react native reanimated”:“^1.0.1”,“react native web”:“^0.11.4”,“react navigation”:“^3.11.1”},“DevDependences”:{“巴贝尔预设博览会”:“^5.1.1”},“private”:true}我的意思是,已安装的依赖项包括react native dependency.C:\Users\Jituni\bholmentorworld>expo——版本3.1。2@DragonWhilte,非常感谢您提供的解决方案。不过我有一些问题。1.对不起,我不理解“合并依赖项”的含义”“我该怎么办?2.如果我创建了一个新项目,我可以保留我在原始项目中编写的代码吗?请建议Blank expo项目有package.json,它包含必要的依赖项,因此您可以复制和粘贴您的包设置,然后删除重复的。然后复制和粘贴除package.json之外的所有代码。然后进行第二步。谢谢。我也这样做了,但面临着新的问题。不管怎样,你的回答很有帮助
{
"dependencies": {
"eslint": "^6.2.1",
"expo": "^33.0.0",
"firebase": "^6.4.0",
"react": "16.8.3",
"react-dom": "^16.8.6",
"react-native-gesture-handler": "^1.2.2",
"react-native-reanimated": "^1.0.1",
"react-native-web": "^0.11.4",
"react-navigation": "^3.11.1"
}
}