Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chokidar throws "Can't resolve 'fsevents'" warning on Windows #48

Closed
vinceau opened this issue Apr 15, 2020 · 2 comments
Closed

chokidar throws "Can't resolve 'fsevents'" warning on Windows #48

vinceau opened this issue Apr 15, 2020 · 2 comments
Labels
dependencies Pull requests that update a dependency file

Comments

@vinceau
Copy link
Owner

vinceau commented Apr 15, 2020

After the #45 PR was merged, on Windows machines it will still try to import fsevents despite not being supported. This seems to not impact the building of the binary using yarn run dist but seems to halt yarn run start.

The stack trace of the warning message is as follows:

        WARNING in ./node_modules/@vinceau/slp-realtime/node_modules/chokidar/lib/fsevents-handler.js
        Module not found: Error: Can't resolve 'fsevents' in 'D:\a\project-clippi\project-clippi\node_modules\@vinceau\slp-realtime\node_modules\chokidar\lib'
         @ ./node_modules/@vinceau/slp-realtime/node_modules/chokidar/lib/fsevents-handler.js
         @ ./node_modules/@vinceau/slp-realtime/node_modules/chokidar/index.js
         @ ./node_modules/@vinceau/slp-realtime/dist/index.es.js
         @ ./src/common/fileProcessor.ts
         @ ./node_modules/ts-loader??ref--13-0!./src/common/workers/fileProcessor.worker.ts

A workaround for the issue is to delete lines 8-12 from the node_modules/@vinceau/slp-realtime/node_modules/chokidar/lib/fsevents-handler.js.

try {
  fsevents = require('fsevents');
} catch (error) {
  if (process.env.CHOKIDAR_PRINT_FSEVENTS_REQUIRE_ERROR) console.error(error);
}

Not really sure how to fix this since the error is happening from the actual require() statement and not coming from the catch and subsequent console.error().

This issue only affects Windows.

@vinceau vinceau added help wanted Extra attention is needed dependencies Pull requests that update a dependency file labels Apr 15, 2020
@vinceau vinceau changed the title Fix fsevents compilation warning/error on Windows Fix chokidar/fsevents compilation warning/error on Windows Apr 15, 2020
@vinceau vinceau changed the title Fix chokidar/fsevents compilation warning/error on Windows Fix chokidar and fsevents compilation warning on Windows Apr 15, 2020
@vinceau vinceau changed the title Fix chokidar and fsevents compilation warning on Windows chokidar throws import warning about fsevents on Windows Apr 15, 2020
@vinceau vinceau changed the title chokidar throws import warning about fsevents on Windows chokidar throws "Can't resolve 'fsevents'" warning on Windows Apr 15, 2020
@totymedli
Copy link

There is an issue on Chokidar's repo for the same problem. Over there I explained a solution. It is still kind of a workaround, but you don't need to change a 3rd party dependency's code:

Just mock the fsevents module then create an alias for it so webpack can resolve the require:

fsevents.js:

module.exports = undefined

In webpack.config.js:

resolve: {
  alias: {
    fsevents$: path.resolve(__dirname, `fsevents.js`),
  },
},

I explain this in detail on Stack Overflow

vinceau added a commit that referenced this issue Jun 4, 2021
@vinceau
Copy link
Owner Author

vinceau commented Jun 4, 2021

Thanks for your comment. You've inspired a fix which does not break fsevents on MacOS which your solution unfortunately does. See below or 5bda5f0.

Simply add this to the webpack.config.js file.

  if (process.platform !== "darwin") {
    context.plugins.push(
      new webpack.IgnorePlugin({
        resourceRegExp: /^fsevents$/,
      })
    );
  }

@vinceau vinceau closed this as completed Jun 4, 2021
vinceau added a commit that referenced this issue Jun 4, 2021
@vinceau vinceau removed the help wanted Extra attention is needed label Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

No branches or pull requests

2 participants