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

Error: Cannot find module 'fsevents' #828

Closed
lemonnm opened this issue Apr 25, 2019 · 19 comments
Closed

Error: Cannot find module 'fsevents' #828

lemonnm opened this issue Apr 25, 2019 · 19 comments

Comments

@lemonnm
Copy link

lemonnm commented Apr 25, 2019

Describe the bug
When precompile assets :

Error: Cannot find module 'fsevents' from '/home/bas/app_8f0c7269-96f9-445b-a4f0-8b9ed34d7058/node_modules/chokidar/lib'

Versions (please complete the following information):

  • Chokidar version : chokidar "^2.0.2"
  • Node version : Install via Yarn
  • OS version: Linux (sorry no more detail my server production is like an Heroku)

During Yarn Install

info "fsevents@1.2.8" is an optional dependency and failed compatibility check. Excluding it from installation.

Use
My application is a Rails App 5.2 and I use gem "browserify-rails".

Chokidar is a dependency of "watchpack".
"watchpack" is a dependency of "webpack".

Question
Why "fsevents" optionalDependency fail when compile assets?

Thanks,

@paulmillr
Copy link
Owner

paulmillr commented Apr 25, 2019

fsevents is only installed for macos. It is not installed on Linux. You should not be seeing this error "Cannot find module 'fsevents' from" at all. So, kinda strange.

Solution:
rm -rf node_modules package-lock.json yarn.lock
and then
npm install or
yarn install

Ensure you are using chokidar v3 and higher! Chokidar v2 uses fsevents v1, which is deprecated. Note: you will need to use node.js v8.10 or higher for chokidar v3.

@ghost
Copy link

ghost commented May 15, 2019

You can delete your node_modules folder and yarn.lock file and run yarn install again this works for me

@usman-servicepath
Copy link

I am getting same error on Windows

@jeanlescure
Copy link

I'm getting the same error on Manjaro with chokidar v3.4.0

@smrtyviks87
Copy link

I am getting the same error on Windows for chokidar version 2.0
Any update or resolution on this issue?

@RicardoBastos
Copy link

look in top file, can be import same this "const { ContextReplacementPlugin } = require("webpack");"

@RodPaDev
Copy link

I'm having the same problem with Chokidar v3.5.1 on Kubuntu 20.04 LTS

@Zaphod-Beeblebrox
Copy link

Zaphod-Beeblebrox commented Apr 8, 2021

I have an Electron App (writtten in VUE). that uses chokidar to watch file system events. complile just started to fail with:
ning in ./node_modules/chokidar/lib/fsevents-handler.js

Module not found: Error: Can't resolve 'fsevents' in 'C:\Code\sidekick\node_modules\chokidar\lib'
version:
"chokidar": "^3.5.1",

the app actually compiles despite this error, but upon running, I get a webpack error:

Uncaught TypeError: The "original" argument must be of type Function
at promisify (util.js?3022:602)
at Object.eval (index.js?b048:9)
at eval (index.js:284)
at Object../node_modules/readdirp/index.js (chunk-vendors.js:9146)
at webpack_require (index.js:849)
at fn (index.js:151)
at Object.eval (index.js?b44e:7)
at eval (index.js:969)
at Object../node_modules/chokidar/index.js (chunk-vendors.js:1804)
at webpack_require (index.js:849)

This setup was working fine until just recently. Not really sure where to go from here.

thanks,

-Mike

additional info. i'm on a windows 10 machine, so fsevents shouldn't even be called, right?

@vitali-ausianik
Copy link

So how to fix it? I have it with version 3.5.1.

@softwareCobbler
Copy link

I was getting this error during JS debugging sessions; turns out I had left my "break on caught exceptions" box checked. Maybe that's helpful to someone.

@mkamran67
Copy link

Tried above solutions still getting this error. I'm on Windows 10 too. The package for me causing this is 'electron-reloader'
. It uses chokidar 3.5.0, tried cleaning reinstalling everything.

@totymedli
Copy link

I was able to solve (workaround) this issue by mocking the fsevents module then creating 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
Copy link

vinceau commented Jun 4, 2021

I've found a workaround inspired by @totymedli which does not break fsevents on MacOS and does not require a separate file.

If you're using Webpack, simply add the following to your webpack.config.js file.

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

@totymedli
Copy link

That is indeed a better solution however I would write it like this:

const { IgnorePlugin } = require('webpack');

const optionalPlugins = [];
if (process.platform !== "darwin") {
  optionalPlugins.push(new IgnorePlugin({ resourceRegExp: /^fsevents$/ }));
}

module.exports = {
  // other webpack config options here...
  plugins: [
    ...optionalPlugins,
  ],
};

@hassanrazase
Copy link

I was getting this error during JS debugging sessions; turns out I had left my "break on caught exceptions" box checked. Maybe that's helpful to someone.

This solved my problem, I was using VSCode and i dont know somehow, my checkbox for "Caught Exception" was marked.
Unchecking it resovled the problem while debugging-session in nodejs App.

@erodrigues-dev
Copy link

I was getting this error during JS debugging sessions; turns out I had left my "break on caught exceptions" box checked. Maybe that's helpful to someone.

This solved my problem, I was using VSCode and i dont know somehow, my checkbox for "Caught Exception" was marked. Unchecking it resovled the problem while debugging-session in nodejs App.

Thanks @hassanrazase
I had the same problem here, I was trying to solve this for 2 days already, you saved my day

@dalgharib
Copy link

dalgharib commented May 6, 2022

Module not found: Error: Can't resolve 'fsevents' in '/node_modules/chokidar/lib'
package.json -version:
"chokidar": "^3.5.3",

Uncaught TypeError: The "original" argument must be of type Function

I have an Electron App (writtten in VUE). that uses chokidar to watch file system events. complile just started to fail with: ning in ./node_modules/chokidar/lib/fsevents-handler.js

Module not found: Error: Can't resolve 'fsevents' in 'C:\Code\sidekick\node_modules\chokidar\lib' version: "chokidar": "^3.5.1",

the app actually compiles despite this error, but upon running, I get a webpack error:

Uncaught TypeError: The "original" argument must be of type Function at promisify (util.js?3022:602) at Object.eval (index.js?b048:9) at eval (index.js:284) at Object../node_modules/readdirp/index.js (chunk-vendors.js:9146) at webpack_require (index.js:849) at fn (index.js:151) at Object.eval (index.js?b44e:7) at eval (index.js:969) at Object../node_modules/chokidar/index.js (chunk-vendors.js:1804) at webpack_require (index.js:849)

This setup was working fine until just recently. Not really sure where to go from here.

thanks,

-Mike

additional info. i'm on a windows 10 machine, so fsevents shouldn't even be called, right?

I`m in Linux Centos7, and I have exactly the same error? Please help

@akkumar
Copy link

akkumar commented Jul 4, 2022

**totymedli ** c

Ran into a similar issue on ubuntu (22.04, if that matters at all ).

The solution by @totymedli - helped fix the issue.

@Yana-Work
Copy link

Are there any updates to this error on Windows?

  • Chokidar version : "^3.5.3"
  • OS version: Windows 10 Pro N
  • npm v9.3.1

Please help me with the following error:
WARNING in ./node_modules/glob-watcher/node_modules/chokidar/lib/fsevents-handler.js 7:17-36
Module not found: Error: Can't resolve 'fsevents' in 'C:..\node_modules\glob-watcher\node_modules\chokidar\lib'

I have tried the following options:

  • npm install --no-optional - It did not help, after using the command I get the same error;
  • resolve: { fallback: { "fsevents": false } }; - the error is not displayed, but other modules still work incorrectly;
  • rm -rf node_modules / rm package-lock.json / npm install - have the same error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests