简体   繁体   English

每当我在 react 上运行 npm start 时,它都会出错。 下图

[英]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.

相关问题 'npm start' 命令无法运行我的 Nodejs API 并给出以下错误 - 'npm start' command fails to run my Nodejs API and gives below error 每当我尝试运行 Cypress Suite 时都会出现以下错误 - Getting below error whenever I try to run Cypress Suite 尝试在 discord 机器人上运行 npm 启动,但我不断收到“节点:事件”错误。 使用节点 v16.13.1 时 - trying to run npm start on a discord bot but i keep getting a 'node:events' error. While using node v16.13.1 在我通过“npm i nodemon”安装 nodemon 后,当我尝试通过“nodemon server.js”运行它时,它给了我这个错误。 我应该怎么办? - After I installed nodemon by "npm i nodemon" , when I tried to run it by "nodemon server.js" , it gives me this error. What should I do? 使用 npx create-react-app 创建应用后<myproject> ,并使用“npm start”启动应用程序我得到了下面提到的这个错误</myproject> - After creating app using npx create-react-app <myproject> , and start app by using "npm start" i got this error mentioned below npm 在创建反应应用程序后在 cmd 上启动总是给出错误 - npm start on cmd after creating react app always gives error 当我在react项目上运行“ npm start”时,网络地址在我的手机上不起作用 - When i run “npm start” on my react project, the network address doesn't work on my phone 我试图运行命令“npm run start”,它在 react js 中显示了这个错误 - I tried to run command “npm run start ” and it showd up with this error in react js 为什么在运行 npm 运行启动时总是出现此错误? 这是 React 的导入错误 - Why do I keep getting this error when running npm run start? It's an import error on React 为什么在 react 中运行 npm start 时出现错误? - Why am I getting error when I run npm start in react?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM