新创建项目的"npm start"错误



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

我已经试过了。

  • 删除node_module文件夹,然后 npm 安装
  • 清除节点缓存。
  • 重新安装节点.js
  • 创建新项目。
  • 减少"反应脚本"的版本
  • 卸载节点.js并删除c盘中名为"node"的所有文件
  • 正在安装旧版本的节点.js

错误是,

C:SurangaReactJSJMSLmy_app>npm start
> my_app@0.1.0 start C:SurangaReactJSJMSLmy_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:UsersAdministratorAppDataRoamingnpm-cache_logs2019-09-10T15_10_01_727Z-debug.log
C:SurangaReactJSJMSLmy_app>

出于存档目的,以下是 OP 报告的解决方案。

降级到反应脚本 2.1.8。

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

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

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

1( 安装巧克力窗 (https://chocolatey.org/(
2( 使用 choco 安装 npm (">choco install nodejs-latest"(
3( npm start

最新更新