fsevents causes Module parse failed: Unexpected character '�'

前提是你 提交于 2021-01-27 05:22:18

问题


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.


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/64103792/fsevents-causes-module-parse-failed-unexpected-character

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!