首页 > 解决方案 > 模块解析失败:意外字符“�”需要适当的加载程序

问题描述

我尝试使用 google 电子表格 npm 包将 Next JS 应用程序中的表单连接到 google 表格。我遇到了一个问题,错误如下:

error - ./node_modules/google-auth-library/build/src/auth/googleauth.js:17:0 Module not found: Can't resolve 'child_process' null

我通过改变我的 next.config.js 从

const withImages = require('next-images');

module.exports = { ...withImages(), trailingSlash: true };

const withImages = require('next-images');

module.exports = {
    ...withImages(),
    trailingSlash: true,
    webpack: (config) => {
        config.node = {
            fs: 'empty',
            child_process: 'empty',
            net: 'empty',
            dns: 'empty',
            tls: 'empty'
        };
        return config;
    }
};

但更改后我收到一个新错误:

error - ./src/assets/images/logo/logo.png 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)

有什么办法可以纠正这个吗?

PS:我在编码部分使用类型脚本。

标签: reactjstypescriptnext.jsconfig

解决方案


推荐阅读