我在react应用程序中有一个带有typescript的express服务器。当我运行npm run dev时,服务器运行得很好,但是当我在终端的另一个会话中运行npm start时,tsconfig.json中的模块会自动从commonJS更改为esnext。服务器已关闭,因为模块已更改。有人能帮我解决这个问题吗?
下面是当我在tsconfig.json中运行npm start时,模块是如何从commonJS更改为esnext的
{
"compilerOptions": {
"target": "ES2020",
--> "module": "commonJS",
"jsx": "react-jsx",
"strict": true,
"outDir": "./build",
"rootDir": "./src",
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"allowSyntheticDefaultImports": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"incremental": true
},
"include": [
"src"
]
}{
"compilerOptions": {
"target": "ES2020",
--> "module": "esnext",
"jsx": "react-jsx",
"strict": true,
"outDir": "./build",
"rootDir": "./src",
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"allowSyntheticDefaultImports": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"incremental": true
},
"include": [
"src"
]
}发布于 2021-08-12 19:58:51
问题是我想使用react应用程序和带有typescript的express服务器。因此,如果我们想做到这一点,我们应该将客户端和服务器端分开。当我问这个问题时,我没有这样做,medium中的?和this article详细解释了这一点。
希望这是清楚的!!
https://stackoverflow.com/questions/68747662
复制相似问题