简体   繁体   English

npm start 脚本在安装 create-react-app my-first-react-app 后立即返回错误

[英]npm start script returns error immediately after installing create-react-app my-first-react-app

As the title states, I just installed the react library and went to start the application for the first time.正如标题所述,我刚刚安装了 react 库并第一次启动了应用程序。 I'm getting the following error below.我在下面收到以下错误。

From what I can tell, it seems that the application is looking into the wrong folder to find the starter script.据我所知,该应用程序似乎正在查看错误的文件夹以查找启动脚本。 I've not altered any of the initial starter files, or added any of my own.我没有更改任何初始启动文件,也没有添加我自己的任何文件。 I'm unsure how to address this issue.我不确定如何解决这个问题。

npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\David\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\David\AppData\Roaming\npm-cache\_logs\2019-12-28T21_32_24_438Z-debug.log```

I think you forgot to cd into (or to change to) your project's directory.我认为您忘记cd进入(或更改到)您的项目目录。

Assuming that you initialised your project in the directory C:\\Users\\David and gave the project name my-app , just type cd my-app (or to be precise type cd C:\\Users\\David\\my-app\\ in your Command Prompt and then run npm start .假设您在目录C:\\Users\\David初始化了您的项目,并将项目名称命名为my-app ,只需键入cd my-app (或者更准确地说,在您的目录中键入cd C:\\Users\\David\\my-app\\命令提示符,然后运行npm start

The file the error message is complaining about, package.json , is already available inside your project folder.错误消息所抱怨的文件package.json已在您的项目文件夹中可用。

However, installing create-react-app and then initialising a new app is not the new recommended way.然而,安装create-react-app然后初始化一个新的应用程序并不是推荐的新方法。

According to the React documentation , uninstall the create-react-app global npm package and follow the following steps to create a new React app:根据React 文档,卸载create-react-app全局 npm 包,然后按照以下步骤创建新的 React 应用程序:

npx create-react-app my-app
cd my-app
npm start

Note笔记

npx on the first line is not a typo — it's a package runner tool that comes with npm 5.2+. npx第一行是不是一个错字-这是一个包亚军工具自带的NPM 5.2+。

暂无
暂无

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

相关问题 使用 npm 安装 create-react-app 时出错 - Error installing create-react-app with npm 在创建反应项目时在“npx create-react-app my-app”之后运行命令“npm start”时出错 - getting error when run command 'npm start' after 'npx create-react-app my-app' in creating a react project 无法运行 NPM 在 create-react-app 之后启动 - Not able to run NPM Start after create-react-app 在npm上启动启动应用程序时出错 - Getting error on npm start create-react-app create-react-app 和 npm 启动时出现错误“找不到模块” - Error "Module not found" while create-react-app and npm start 使用 npm 安装 create-react-app 时出错,使用 npm init react-app 时出错 - error installing create-react-app using npm & error when using npm init react-app create-react-app 无法启动脚本后 - after create-react-app failed to start script 使用 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 在运行“create-react-app my-app”后尝试运行“npm start”时出现一堆错误 - Get a bunch of errors when trying to run “npm start” after running “create-react-app my-app” 使用 create-react-app 创建新的 react 项目后,npm start 失败 - npm start fails after creating a new react project using create-react-app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM