reactjs - 模块解析失败:意外字符“�”需要适当的加载程序
问题描述
我尝试使用 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:我在编码部分使用类型脚本。
解决方案
推荐阅读
- php - Laravel 中间件类调用捕获
- python - 提高 scikit-learn 多项逻辑回归的速度
- javascript - 使用 JavaScript 记住图像和 div 的切换状态
- cygwin - 为什么 pandoc 在 cygwin 上的某些路径有问题?
- html - iOS 上 Input type="time" 的设置值总是将值设置为当前时间
- r - 在 R 中使用不同版本的包
- arrays - 使用二分搜索定理的两个排序数组的中位数
- java - 我该如何解决下面提到的问题?
- linux - 我正在尝试安装 docker 并在设置 docker-ce (5:19.03.12~3-0~ubuntu-xenial) 处挂起
- c# - Form.Show() 不允许键盘输入