首页 > 解决方案 > TypeError: fsevents is not a constructor(已经试过一堆答案)

问题描述

我正在关注 Maximilian Schwarzmüller 的反应教程 (udemy)

sudo npm install create-react-app -g

然后:

create-react-app react-complete-guide --scripts-version 1.1.5

一切都很好(毫无疑问,有一些警告)

然后,我 cd 进入文件夹npm start

首先我得到了这个错误: sh: react-scripts: command not found

从这个链接的建议:https ://github.com/facebook/create-react-app/issues/6594

我试过了:PATH=$PATH:./node_modules/.bin npm start

它可以启动一个浏览器并且它工作!

但这里是事情开始变得糟糕的时候:

在线程中,同一个人建议:Install the package in the global npm install -g react-scriptsyarn global react-scripts。然后,它可以在不设置环境的情况下执行(PATH=$PATH:...)。

所以我做了 npm install -g react-scripts

我开始收到错误:

TypeError: fsevents is not a constructor

我所知道的是这个错误应该很常见。我已经尝试了我遇到的所有解决方案:安装 yarn npm uninstall -g create-react-app,然后npx create-react-app my-app. 我也试过

npm audit fix --forcenpm i fsevents

但没有任何效果。它仍然向我展示了相同的TypeError: fsevents is not a constructor

我觉得我可能搞砸了我的终端。我可能拔掉了我头上的一半头发。请帮助我~如果有任何建议,我将不胜感激~OTL

标签: node.jsreactjsnpmyarnpkg

解决方案


对于这个错误

TypeError:fsevents 不是构造函数

我必须在我的 Mac 上安装 watchman https://create-react-app.dev/docs/troubleshooting/#npm-test-hangs-or-crashes-on-macos-sierra

brew install watchman

推荐阅读