首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >自动更改tsconfig.json中的模块值

自动更改tsconfig.json中的模块值
EN

Stack Overflow用户
提问于 2021-08-11 19:08:04
回答 1查看 18关注 0票数 0

我在react应用程序中有一个带有typescript的express服务器。当我运行npm run dev时,服务器运行得很好,但是当我在终端的另一个会话中运行npm start时,tsconfig.json中的模块会自动从commonJS更改为esnext。服务器已关闭,因为模块已更改。有人能帮我解决这个问题吗?

下面是当我在tsconfig.json中运行npm start时,模块是如何从commonJS更改为esnext

代码语言:javascript
复制
{
  "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"
  ]
}
代码语言:javascript
复制
{
  "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"
  ]
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-08-12 19:58:51

问题是我想使用react应用程序和带有typescript的express服务器。因此,如果我们想做到这一点,我们应该将客户端和服务器端分开。当我问这个问题时,我没有这样做,medium中的?和this article详细解释了这一点。

希望这是清楚的!!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68747662

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档