typescript - 模块解析失败:意外字符 '�' (1:0) NEXTJS NESTJS
问题描述
我从 webpack 收到这个错误。我已经在https://github.com/thisismydesign/nestjs-starter复制了这个项目,当我尝试从我的资产文件夹中导入图像时,出现以下错误。通常,这些东西开箱即用。可能会发生什么?
提前致谢。
./assets/img/logo.png
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)
我的配置如下:
文件夹结构
src
-client
--assets
--pages
--next.env.d.ts
--next.config.js
--tsconfig.json
...
-server
-...
下一个.env.d.ts
/// <reference types="next" />
/// <reference types="next/types/global" />
declare module '*.png' {
const value: any;
export default value;
}
next.config.js
module.exports = {
distDir: '../../.next',
module: {
rules: [
{
test: /\.(png|jpg|gif)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 8192,
},
},
],
},
],
},
};
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": [
"next-env.d.ts",
"next.config.js",
"app",
"pages",
"components",
"assets",
"store"
],
"exclude": ["node_modules"]
}
解决方案
推荐阅读
- hyperledger-composer - Hyperledger Composer 网络部署问题:未找到卡
- javascript - Angular 6为每个服务器调用获取相同的API数据,直到我刷新应用程序
- sql - 这个与 SQL 相关的问题是什么意思?
- android - Dagger 2 和 Android 数据绑定适配器:不能在没有 @Inject 或 @Provides 的情况下提供
- google-chrome - Chrome 检查窗口工具栏缩小,无法恢复为默认值
- c - ffmpeg RTSP over TCP,RTP时间戳始终为零
- java - 为什么成功功能在spring mvc中不起作用
- laravel - 我的 app.js vue 文件什么也没做
- angular - 我想作为变量捕获并在提交时添加到新 SharePoint 列表的 Angular 表单新字段
- android - 在 Android Studio 中实现多合一事件日历