[英]whenever i run npm start on my react it gives an error. Image below
enter image description here image of the error message am getting在此处输入图像描述我收到的错误消息的图像
2 : Tried yarn start getting same error message [3]: Tried npm install react-scripts [4]: The second image is after i tried cd real_app and trying the link on the error message 2 :试过纱线开始得到相同的错误消息 [3]:试过 npm install react-scripts [4]:第二张图片是在我尝试 cd real_app 并尝试错误消息上的链接之后
You are in the wrong directory.你在错误的目录中。 Looking at you file structure I can see that you are trying to start the app inside of:
查看您的文件结构,我可以看到您正在尝试在以下位置启动应用程序:
C:\Users\HP\Desktop\Python Worx\react\app
However as the error denotes it cannot find the package.json file.但是,由于错误表明它找不到 package.json 文件。 That is because your project path (where package.json is located) is actually:
那是因为您的项目路径(package.json 所在的位置)实际上是:
C:\Users\HP\Desktop\Python Worx\react\app\real_app
In your terminal there type:在您的终端中输入:
cd real_app
Then run your npm start.然后运行你的 npm start。
It seems to me that you are trying to run npm start
in the wrong directory.在我看来,您试图在错误的目录中运行
npm start
。 You are running the command in a directory called /app
, and in the navigator pane to the left it shows that package.json
is in a directory called real_app
.您正在名为
/app
的目录中运行该命令,并且在左侧的导航器窗格中,它显示package.json
位于名为real_app
的目录中。
You need to run those npm commands in the root directory of your app, where package.json
is.您需要在应用程序的根目录(
package.json
所在的目录)中运行这些 npm 命令。
To find the correct directory you can right click real_app
on the left pane and select Open in Terminal
, and try to run the npm command from there.要找到正确的目录,您可以右键单击左侧窗格中的
real_app
并选择Open in Terminal
,然后尝试从那里运行 npm 命令。
Hope that helps!希望有帮助!
I had many react files in that particular folder, had to find the real_app and did the npm start there and it worked.我在那个特定的文件夹中有很多反应文件,必须找到 real_app 并在那里启动 npm 并且它起作用了。 Had to delete all other react files that i wasnt working with, guess the npm start was looking for the instance of the first react app I downloaded and that was why I was getting the error message.
不得不删除我没有使用的所有其他反应文件,猜测 npm start 正在寻找我下载的第一个反应应用程序的实例,这就是我收到错误消息的原因。 Thanks to @Sammy I. and @basic for your help, without you guys would not have gotten this solved.
感谢@Sammy I. 和@basic 的帮助,没有你们就无法解决这个问题。 enter image description here
在此处输入图片说明
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.