Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fsevents causes Module parse failed: Unexpected character '�'

I am using next.js and I get:

Failed to compile.

./node_modules/fsevents/fsevents.node 1:0
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)

I tried almost everything, most recently, to package.json, I added:

    "optionalDependencies": {
        "fsevents": "^2.1.3"
    }

In next.config.js, I have:

const withImages = require("next-images");
const withPlugins = require("next-compose-plugins");
const withCSS = require("@zeit/next-css");

module.exports = withPlugins([
    withCSS,
    withImages,
]

Not sure what else to do.

like image 670
Shamoon Avatar asked Sep 28 '20 14:09

Shamoon


2 Answers

I fixed it in my VS Code extension by adding:

{
  test: /.node$/,
  loader: 'node-loader',
}

to the module.rules in webpack.config.js and adding:

    "node-loader": "^1.0.1",

to the devDependencies in package.json

like image 153
treckle Avatar answered Oct 23 '22 01:10

treckle


Try check what encoding used in fsevents.node I was getting similar exception. Problem was in UTF-16 encoding of file. Changed to UTF-8 and it did help.

like image 1
Матвей Куприянов Avatar answered Oct 23 '22 00:10

Матвей Куприянов