fsevents导致模块解析失败:意外字符'�'

11

我正在使用next.js,并且出现以下问题:

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)

我几乎尝试了所有方法,最近我在 package.json 中添加了以下内容:

    "optionalDependencies": {
        "fsevents": "^2.1.3"
    }
next.config.js文件中,我有以下配置:
const withImages = require("next-images");
const withPlugins = require("next-compose-plugins");
const withCSS = require("@zeit/next-css");

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

不确定还有什么其他可做的。

2个回答

阿里云服务器只需要99元/年,新老用户同享,点击查看详情
19

我在我的VS Code扩展中修复了它,方法是添加:

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

webpack.config.js 中的 module.rules 中添加:

    "node-loader": "^1.0.1",

package.json中的devDependencies进行更新


2

尝试检查fsevents.node使用的编码方式,我遇到了类似的异常。问题出在文件的UTF-16编码上,改为UTF-8后问题得以解决。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,