简体   繁体   English

在 create-react-app 后 npm start 不起作用

[英]npm start not working after create-react-app

I am trying to create a react app with the below steps:我正在尝试通过以下步骤创建一个反应应用程序:

  1. npm install -g create-react-app npm install -g create-react-app
  2. create-react-app my-app创建反应应用程序我的应用程序
  3. cd my-app cd 我的应用程序
  4. npm start启动

And I get this error:我得到这个错误:

在此处输入图片说明

In error have suggestion to remove webpack dependency but i cant do that because in file package.json dun have that.错误地建议删除 webpack 依赖项,但我不能这样做,因为在文件 package.json 中没有那个。 Here my package.json这是我的 package.json

在此处输入图片说明

For additional information:如需更多信息:

  • i am using windows 10我正在使用 Windows 10
  • npm 6.4.1 npm 6.4.1
  • create-react-app version 2.0.3 create-react-app 版本 2.0.3
  • node v8.12.0节点 v8.12.0

Just do following steps:只需执行以下步骤:
- delete package-lock.json. - 删除 package-lock.json。
- delete node_modules. - 删除 node_modules。
- npm install. - npm 安装。

Or或者

Just try steps mentioned in the error log and you will be fine .只需尝试错误日志中提到的步骤,您就会没事的。 在此处输入图片说明

Do step number 6 and delete that babel loader or webpack folder and you will be good afterwards.执行第 6 步并删除那个 babel loader 或 webpack 文件夹,之后你会很好。 Chances are you have an outdated web pack or babel that you installed in a previous project.您可能有一个过时的 web pack 或 babel,是您在之前的项目中安装的。

I just had this very issue, and turns out to be something simple我刚刚遇到了这个问题,结果很简单

The part of the log that says about there being a日志中说明存在一个

"a different version of webpack was detected higher up in the tree" “在树的更高位置检测到不同版本的 webpack”

looks to be the same case for you.看起来和你一样。 I think you may have ran npm install at some point under D:\\bolehDiHapus and so have node_modules installed further up the tree that you meant.我认为您可能已经在 D:\\bolehDiHapus 下的某个点运行了npm install ,因此将 node_modules 安装在您所指的树的更远的位置。

I simply changed the name of D:\\bolehDiHapus\\node_modules (probably best to just delete it) and hey presto npm start works.我只是更改了 D:\\bolehDiHapus\\node_modules 的名称(可能最好只是删除它),嘿,presto npm start有效。

I had this same issue, first it started saying we found the wrong version farther up in the tree, and then i had to delete webpack up there, and then i had install their "required version" even if it is lower than latest.我遇到了同样的问题,首先它开始说我们在树中更远的地方找到了错误的版本,然后我不得不删除那里的 webpack,然后我安装了他们的“所需版本”,即使它低于最新版本。

npm install webpack@version --save

in your case: npm install --save webpack@4.19.1在你的情况下: npm install --save webpack@4.19.1

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

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