我正在使用 Next.js 和 TypeScript 构建一个 Web 应用程序。我有一个自定义server.ts
文件。因此,我的开发命令是ts-node server.ts
. 一切正常,直到现在:( 每次我尝试运行命令时,我的 tsconfig.json 文件都会更改。
我已经尝试了最基本的解决方案,例如删除node_modules
目录并npm install
再次运行命令或重新安装整个 Node.js。不幸的是,没有什么对我有用。
这是我的tsconfig.json
文件:
{
"compileOnSave": false,
"compilerOptions": {
"target": "es2017",
"module": "esnext",
"jsx": "preserve",
"allowJs": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"removeComments": false,
"preserveConstEnums": true,
"sourceMap": true,
"skipLibCheck": true,
"baseUrl": ".",
"typeRoots": [
"./types",
"./node_modules/@types"
],
"lib": [
"dom",
"esnext"
],
"outDir": "dist/",
"incremental": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true
},
"include": [
"pages/*",
"components/*",
"server.ts"
],
"exclude": [
"node_modules",
"**/*.spec.ts",
"**/*.spec.tsx",
"**/*.test.ts",
"**/*.test.tsx",
"jest.config.js",
"jest.setup.js",
"next.config.js"
]
}
这是我运行后收到的消息ts-node server.ts
:
The following changes are being made to your tsconfig.json file:
- compilerOptions.strict to be suggested value: true (this can be changed)
- compilerOptions.forceConsistentCasingInFileNames to be suggested value: true (this can be changed)
- compilerOptions.esModuleInterop must be true (requirement for babel)
- compilerOptions.module must be esnext (for dynamic import() support)
- compilerOptions.resolveJsonModule must be true
- compilerOptions.isolatedModules must be true (requirement for babel)
- compilerOptions.noEmit must be true