【问题标题】:Error in "npm start" for newly created project新创建项目的“npm start”错误
【发布时间】:2020-01-12 09:43:00
【问题描述】:

我刚刚创建了一个 react js 项目。然后我运行“npm start”来运行项目。这个错误来了,我现在被困在这里 1 天。我已经有其他 reactJS 项目。所有其他项目都出现此错误。这就是为什么我在新项目中尝试它的原因。所以我通过创建新项目来确认。错误不在我的项目中。

我已经试过了。

  • 删除 node_module 文件夹然后 npm install
  • 清除节点缓存。
  • 重新安装node.js
  • 创建新项目。
  • 降低'react-script'的版本
  • 卸载node.js并删除c盘所有名为“node”的文件
  • 安装旧版本的 node.js

错误是,

C:\Suranga\ReactJS\JMSL\my_app>npm start

> my_app@0.1.0 start C:\Suranga\ReactJS\JMSL\my_app
> react-scripts start
> Starting the development server...
events.js:174
      throw er; // Unhandled 'error' event
      ^
Error: spawn cmd ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
Emitted 'error' event at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my_app@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my_app@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2019-09-10T15_10_01_727Z-debug.log
C:\Suranga\ReactJS\JMSL\my_app>

【问题讨论】:

  • 你能在codesandbox.io 中复制这个吗?
  • events.js:174这个文件的内容是什么?
  • CRA github issue 有帮助吗?
  • 检查您的环境变量 PATH。见stackoverflow.com/a/28626189/12030751
  • @It'sNotMe 谢谢。我从这个链接得到了解决方案。我运行“npm install react-scripts@2.1.8”和 npm start。现在它工作正常。

标签: node.js reactjs npm npm-start


【解决方案1】:

首先确保您位于使用 create-react-app 创建的正确应用程序文件夹中。否则,尝试在文件夹中运行npm install

【讨论】:

  • 是的,我正在处理正确的文件夹。谢谢你的回答
【解决方案2】:

出于存档目的,这里是 OP 报告的the solution

降级到 react-scripts 2.1.8。

create-react-app my-app
cd my-app
npm install react-scripts@2.1.8
npm start

【讨论】:

    【解决方案3】:

    其他人仍然有同样的问题。以前的解决方案对于这些项目来说并不成功。最后我按照以下步骤做到了。

    1) 为 windows 安装 Chocolatey (https://chocolatey.org/)
    2) 使用 choco ("choco install nodejs-latest") 安装 npm
    3) npm 启动

    【讨论】:

      猜你喜欢
      • 2023-03-20
      • 2021-03-24
      • 2016-01-17
      • 1970-01-01
      • 1970-01-01
      • 2019-04-27
      • 2021-08-29
      • 2020-05-08
      • 1970-01-01
      相关资源
      最近更新 更多