gpt4 book ai didi

typescript - 不支持通过 'next.config.ts' 的错误 : Configuring Next. js。请将文件替换为 'next.config.js'

转载 作者:行者123 更新时间:2023-12-04 12:57:02 28 4
gpt4 key购买 nike

我正在构建下一个项目的 typescript 。如果我将此配置文件保留为 next.config.js , 我在 tsconfig.json 收到警告说“找不到next.config.ts”。所以 tsconfig.json 在 {} 上有警告标志.
如果我将扩展名更改为 .ts ,当我启动项目时,出现此错误:
“错误:不支持通过 'next.config.ts' 配置 Next.js。请将文件替换为 'next.config.js'。

我很困惑,我不知道该怎么办。
配置文件

{ 
"compilerOptions": {
"target": "es6",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
},
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"sourceMap": true,
"removeComments": true,

"jsx": "preserve"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
下一个.config.ts
const path = require("path");
const Dotenv = require("dotenv-webpack");

module.exports = {
env: {
AUTH0_NAMESPACE: process.env.AUTH0_NAMESPACE,
BASE_URL: process.env.BASE_URL,
},
};

最佳答案

似乎使用 next.config.ts减慢启动速度,因为您必须自己编译它,或者至少 next.js 存储库的成员是这么说的。
有一个问题(更像是一个请求)支持 next.config.ts native 。
Here是关于它的问题,它有其他开发人员的一些解决方案

关于typescript - 不支持通过 'next.config.ts' 的错误 : Configuring Next. js。请将文件替换为 'next.config.js',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65319081/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com