简体   繁体   English

fsevents 不是构造函数

[英]fsevents is not a constructor

Starting the development server...启动开发服务器...

/Users/puneetrangrass/Documents/react/react-practice/node_modules/chokidar/lib/fsevents-handler.js:28
return (new fsevents(path)).on('fsevent', callback).start();
^
TypeError: fsevents is not a constructor
at createFSEventsInstance (/Users/puneetrangrass/Documents/react/react-practice/node_modules/chokidar/lib/fsevents-handler.js:28:11)
at setFSEventsListener (/Users/puneetrangrass/Documents/react/react-practice/node_modules/chokidar/lib/fsevents-handler.js:82:16)
at FSWatcher.FsEventsHandler._watchWithFsEvents (/Users/puneetrangrass/Documents/react/react-practice/node_modules/chokidar/lib/fsevents-handler.js:252:16)
at FSWatcher. (/Users/puneetrangrass/Documents/react/react-practice/node_modules/chokidar/lib/fsevents-handler.js:386:25)
at LOOP (fs.js:1570:14)
at process._tickCallback (internal/process/next_tick.js:61:11)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-practice@0.1.0 start: react-scripts start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-practice@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! /Users/puneetrangrass/.npm/_logs/2019-07-13T05_06_50_503Z-debug.log
puneets-MacBook-Pro:react-practice puneetrangrass$ node --v
node: bad option: --v
puneets-MacBook-Pro:react-practice puneetrangrass$ node -v
v10.16.0
puneets-MacBook-Pro:react-practice puneetrangrass$

in my machine在我的机器里

node : v10.16.0 npm : 6.9.0节点:v10.16.0 npm:6.9.0

while executing " npm start " in react app.在反应应用程序中执行“ npm start ”时。 how can i resolve the issue?我该如何解决这个问题?

Do the following if you still have the issue.如果问题仍然存在,请执行以下操作。

  1. Remove node_modules folder and any lock files ( package.lock ) and package-lock.json .删除node_modules文件夹和所有锁定文件 ( package.lock ) 和package-lock.json Basically your project folder should have only package.json and src folder (Can have .git and Readme.md, but they're not relevant here).基本上你的项目文件夹应该只有 package.json 和 src 文件夹(可以有 .git 和 Readme.md,但它们在这里不相关)。

rm -rf node_modules

rm -rf package-lock.json


  1. Install yarn if you don't have it already.如果您还没有纱线,请安装它。

If you already have npm, then it is as easy as如果你已经有了 npm,那么它就像

npm install -g yarn

Otherwise use this link to install Yarn .否则使用此链接安装Yarn


  1. Navigate to your project folder and type导航到您的项目文件夹并键入

yarn install


  1. Run npm start to start your project.运行npm start来启动你的项目。 Then you should see no more of these errors.那么您应该不会再看到这些错误了。 If you still see them, run npm cache clean --force and start it again.如果您仍然看到它们,请运行npm cache clean --force并重新启动它。

Currently the issue which you are getting is mainly due to chokidar.目前,您遇到的问题主要是由于 chokidar。


I used this github thread to solve as given by ravibagul91 .我使用这个github 线程来解决ravibagul91给出的问题


I had the same=> TypeError: fsevents is not a constructor我有同样的=> TypeError: fsevents is not a constructor

Solution: Inside any created project that has not been ejected, run:解决方案:在任何尚未弹出的已创建项目中,运行:

npm install --save --save-exact react-scripts@3.0.1 npm install --save --save-exact react-scripts@3.0.1

or或者

yarn add --exact react-scripts@3.0.1纱线添加 --exact react-scripts@3.0.1

Reference: https://github.com/facebook/create-react-app/releases/tag/v3.0.1参考: https : //github.com/facebook/create-react-app/releases/tag/v3.0.1

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

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