首页 > 解决方案 > Nuxt.js:fsevents 不是构造函数

问题描述

我正在使用 MacOS Mojave 10.14.5。当我在 nuxt 启动程序包所在的位置运行“npm run dev”命令时,出现“fsevents”错误,并且服务器无法工作。

我已经多次重新安装 node 和 npm,但它不起作用。

这是一个错误:

/Users/kimgyun/Desktop/nuxt_test_folder/nuxt_test_b/node_modules/watchpack/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/kimgyun/Desktop/nuxt_test_folder/nuxt_test_b/node_modules/watchpack/node_modules/chokidar/lib/fsevents-handler.js:28:11)
    at setFSEventsListener (/Users/kimgyun/Desktop/nuxt_test_folder/nuxt_test_b/node_modules/watchpack/node_modules/chokidar/lib/fsevents-handler.js:82:16)
    at FSWatcher.FsEventsHandler._watchWithFsEvents (/Users/kimgyun/Desktop/nuxt_test_folder/nuxt_test_b/node_modules/watchpack/node_modules/chokidar/lib/fsevents-handler.js:252:16)
    at FSWatcher.<anonymous> (/Users/kimgyun/Desktop/nuxt_test_folder/nuxt_test_b/node_modules/watchpack/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! nuxt_test_b@1.0.0 dev: `nuxt`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the nuxt_test_b@1.0.0 dev 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/kimgyun/.npm/_logs/2019-06-06T02_11_18_374Z-debug.log

如何在没有此错误的情况下运行此 nuxt.js 服务器?

标签: vue.jsnuxt.jsfsevents

解决方案


这是 fs 事件的一个问题,而且是一个相当烦人的问题。具体来说,当您使用 Node 12 时会发生这种情况。

您需要明确安装 fsevents@1.2.9:

npm i fsevents@1.2.9 -D

或者

yarn add fsevents@1.2.9 -D

这应该对你有用。


推荐阅读