简体   繁体   English

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

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

While running npm start, I am getting error -在运行 npm 启动时,我收到错误 -

PS D:\React\operations_app_tut> 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\_logs\2020-12-16T05_56_02_304Z-debug.log

While checking physical path made sure file exists -在检查物理路径时确保文件存在 -

在此处输入图像描述

Structure Of Project For Ref -参考项目的结构 -

在此处输入图像描述

I referred few sites and again ran -npm install But same error persisted.我参考了几个站点并再次运行 -npm install 但同样的错误仍然存在。

You are running npm start in incorrect folder.Also why there is package-lock.json outside.您在错误的文件夹中运行npm start 。还有为什么外面有 package-lock.json。

move to D:\React\operations_app_tut\operations_app_tut directory then run npm start移动到D:\React\operations_app_tut\operations_app_tut目录然后运行npm start

Thanks @NitinDev And @Adithya.谢谢@NitinDev 和@Adithya。

Adding details if future contributor faces the same issue -如果未来的贡献者面临同样的问题,请添加详细信息 -

My mistake here was, I had a folder D:/React Within this folder I had all my react projects.我的错误是,我有一个文件夹D:/React在这个文件夹中我有我所有的反应项目。 I manually created - operations_app_tut folder in D:/React我在D:/React中手动创建了operations_app_tut文件夹

After this I opened it through Visual Code via path:- D:/React/operations_app_tut and ran command -在此之后,我通过 Visual Code 通过路径打开它:- D:/React/operations_app_tut并运行命令 -

npx create-react-app operations_app_tut

This command created another folder within operations_app_tut which made my project path to be - D:/React/operations_app_tut/operations_app_tut此命令在operations_app_tut中创建了另一个文件夹,这使我的项目路径为 - D:/React/operations_app_tut/operations_app_tut

Since I was running npm start on terminal with path - D:/React/operations_app_tut which was not the actual path, it was giving me error.由于我在终端上运行 npm 启动路径 - D:/React/operations_app_tut这不是实际路径,因此它给了我错误。

Lesson -课程 -

  1. Do not create Project Folder Manually, it will automatically get created via npx create-react-app不要手动创建项目文件夹,它将通过npx create-react-app自动创建

暂无
暂无

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

相关问题 ENOENT:没有这样的文件或目录,打开 'C:\Users\subwo\package.json' - ENOENT: no such file or directory, open 'C:\Users\subwo\package.json' npm-bundle 失败并出现错误:ENOENT:没有这样的文件或目录,打开“package.json” - npm-bundle fails with Error: ENOENT: no such file or directory, open 'package.json' npm WARN enoent ENOENT:没有这样的文件或目录,打开“C:\Users\Nuwanst\package.json” - npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Nuwanst\package.json' package.json 中的根目录 - Root directory in package.json 创建 React App(npm run build) 生成包含不需要的 package.json 内容的 chunk.js 文件 - Create React App(npm run build) generates chunk.js file with unwanted content of package.json React-chart.js 2 模块错误但已安装在 package.json 文件中 - React-chart.js 2 Error in modules but was already installed in the package.json file 无法在package.json中正确指向start标记以反应js - Not able to point the start tag correctly in package.json for react js Docker 没有这样的文件或目录,打开“/home/todo1/server/package.json”(2021 年 1 月 2 日星期六 09:47:44 UTC 更新) - Docker no such file or directory, open '/home/todo1/server/package.json' (updated 09:47:44 UTC Saturday, 2 January 2021) npm在用户目录中寻找package.json - npm looking for package.json in user directory Npm在错误的目录中搜索package.json - Npm searching for package.json in the wrong directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM