React Js:没有那个文件或目录,打开 Package.json

React Js : no such file or directory, open Package.json

当 运行 npm start 时,出现错误 -

PS D:\React\operations_app_tut> npm 启动

npm ERR! path D:\React\operations_app_tut\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'D:\React\operations_app_tut\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\IT-DI\AppData\Roaming\npm-cache\_logs20-12-16T05_56_02_304Z-debug.log

检查物理路径时确保文件存在 -

供参考的项目结构 -

我参考了几个网站,然后又参考了 运行 -npm install 但同样的错误仍然存​​在。

你运行宁npm start不正确folder.Also为什么外面有包裹-lock.json

移动到D:\React\operations_app_tut\operations_app_tut目录 然后 运行 npm start

感谢@NitinDev 和@Adithya。

如果未来的贡献者面临同样的问题,请添加详细信息 -

我的错误是,我有一个文件夹 D:/React 在这个文件夹中,我有我所有的反应项目。 我在 D:/React

中手动创建了 - operations_app_tut 文件夹

在此之后,我通过路径通过 Visual Code 打开它:- D:/React/operations_app_tut 和 运行 命令 -

npx create-react-app operations_app_tut

此命令在 operations_app_tut 中创建了另一个文件夹,这使我的项目路径成为 - D:/React/operations_app_tut/operations_app_tut

因为我是 运行 npm start on terminal with path - D:/React/operations_app_tut 这不是实际路径,所以它给了我错误。

课-

  1. 不要手动创建项目文件夹,它将通过npx create-react-app
  2. 自动创建