fsevents 导致模块解析失败:意外字符“?”

Sha*_*oon 6 webpack next.js

我正在使用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)
Run Code Online (Sandbox Code Playgroud)

我几乎尝试了所有方法,最近一次package.json,我补充说:

    "optionalDependencies": {
        "fsevents": "^2.1.3"
    }
Run Code Online (Sandbox Code Playgroud)

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,
]
Run Code Online (Sandbox Code Playgroud)

不知道还能做什么。

小智 5

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

{
  test: /.node$/,
  loader: 'node-loader',
}
Run Code Online (Sandbox Code Playgroud)

module.ruleswebpack.config.js 和添加:

    "node-loader": "^1.0.1",
Run Code Online (Sandbox Code Playgroud)

devDependenciespackage.json