Search code examples
vue.jsnuxt.jsfsevents

Nuxt.js: fsevents is not a constructor


I'm using MacOS Mojave 10.14.5. When I run 'npm run dev' command where the nuxt starter package is located, I have 'fsevents' error, and the server doesn't work.

I already reinstall node and npm several times, but it doesn't work.

Here's an error:

/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! [email protected] dev: `nuxt`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] 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

How can I run this nuxt.js server without this error?


Solution

  • It's a problem with fs events, and a rather annoying one at that. Specifically this happens when you're using Node 12.

    You'll need to install [email protected] explicitly:

    npm i [email protected] -D
    

    or

    yarn add [email protected] -D
    

    This should work for you at this point.