typescript - vercel 部署无法需要`.d.ts`文件
问题描述
我的 next.js 应用程序可以在我的机器上运行,但是当部署在 Vercel 上时,它在构建时失败并出现以下错误:
Error! Unable to require `.d.ts` file.
This is usually the result of a faulty configuration or import. Make sure there is a `.js`, `.json` or another executable extension and loader (attached before `ts-node`) available alongside `emotion.d.ts`.
它似乎无法在我的类型文件夹中检测到 Emotion.d.ts。它像 /src/types/emotion.d.ts 一样位于 src 中,所以我尝试更改我的设置以包含如下内容。
{
"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",
"src/**/*"
],
"exclude": [
"node_modules"
]
}
尽管如此,还是没有运气。
我的emotion.d.ts 文件只是简单地声明了一个这样的类型。
import '@emotion/react';
declare module '@emotion/react' {
export interface Theme {
color: {
primary0: string;
primary1: string;
primary2: string;
primary3: string;
primary4: string;
primary5: string;
primary6: string;
primary7: string;
secondary0: string;
secondary1: string;
secondary2: string;
secondary3: string;
secondary4: string;
secondary5: string;
secondary6: string;
tertiary0: string;
tertiary1: string;
tertiary2: string;
text0: string;
text1: string;
text2: string;
text3: string;
text4: string;
bg0: string;
bg1: string;
bg2: string;
};
size: {
maxWidth: string;
};
mediaQuery: {
sp: string;
pc: string;
};
}
}
任何帮助将不胜感激。谢谢!
解决方案
推荐阅读
- git - 未将数据提交到 git 存储库
- css - WooCommerce 店面 - 如何自定义产品目录并减少空白?
- php - 有没有办法在传递 $_SESSION 变量作为参数时从 PHP 调用 mySQL 存储过程?
- android - Http请求拦截不显示任何日志信息
- bash - 在 Bash 中查找所有环境变量
- jestjs - Jest 文件中的要求有多正确?(带有模块模式 js 文件)
- python - 使用Python检查列表元素是否是另一个列表中的子元素
- xml - XQuery - 列出每个大陆上人口最多的国家的名称和人口
- c++ - TDLib:如何在消息中发送粗体文本?(С++)
- javafx - 有没有办法提高 JavaFX 图表刻度线的精度?