我正在尝试在本地环境中运行我的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
这也是文件夹目录的样子。
package.json
文件仍然存在,所以我不明白为什么找不到该文件。
提前谢谢!
答案 0 :(得分:1)
错误消息指出, npm 找不到package.json
文件。您的情况是文件位于src
文件夹中。将文件移至尝试在较早位置运行的根目录中并运行npm start
后,它应该就可以正常运行了。
如果还缺少node_modules
文件夹-该文件夹包含所有已安装的依赖项,以运行您的项目-那么您需要先运行npm install
,它将从package.json
获取所有依赖项并安装它们。
希望对您有帮助!