简体   繁体   English

React Application npm start 出现错误

[英]React Application npm start is giving an error

I am trying to run my React app in the local environment and keep getting the following error我正在尝试在本地环境中运行我的 React 应用程序并不断收到以下错误

PS C:\Users\rafay\OneDrive\Documents\business-website-react-master> npm start
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\rafay\OneDrive\Documents\business-website-react-master\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\rafay\OneDrive\Documents\business-website-react-master\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\rafay\AppData\Roaming\npm-cache\_logs\2020-02-22T20_12_59_502Z-debug.log

Here is what the folder directory looks like as well.这也是文件夹目录的样子。

截屏

the package.json file is still there so i don't understand why the file cannot be located. package.json文件仍然存在,所以我不明白为什么找不到该文件。

Thank you in advance!先感谢您!

As the error message states, npm does not find package.json file.正如错误消息所述, npm找不到package.json文件。 The reason in your case is that the file is located in the src folder.您的情况的原因是该文件位于src文件夹中。 Once you move the file into the root - where you tried to run earlier - and run npm start then it should be just starting fine.一旦你将文件移动到根目录——你之前尝试运行的地方——并运行npm start那么它应该就可以正常启动了。

If the node_modules folder is also missing - which is containing all the installed dependencies to run your project - then you need to run first npm install which will take all the dependencies from package.json and install them.如果node_modules文件夹也丢失了——它包含运行你的项目的所有已安装的依赖项——那么你需要先运行npm install ,这将从package.json获取所有依赖项并安装它们。

I hope that helps!我希望这有帮助!

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

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