首页 > 解决方案 > fsevents 导致模块解析失败:意外字符“�”

问题描述

我正在使用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,
]

不知道还能做什么。

标签: webpacknext.js

解决方案


我通过添加以下内容在我的 VS Code 扩展中修复了它:

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

module.rules添加webpack.config.js

    "node-loader": "^1.0.1",

devDependencies里面package.json


推荐阅读