【问题标题】:change the module value in tsconfig.json automatically自动更改 tsconfig.json 中的模块值
【发布时间】:2021-08-11 19:08:04
【问题描述】:

我在带有打字稿的反应应用程序中有一个快速服务器。当我运行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"
  ]
}

【问题讨论】:

    标签: reactjs typescript express frontend


    【解决方案1】:

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

    希望这很清楚!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-10
      • 1970-01-01
      • 1970-01-01
      • 2022-12-13
      • 1970-01-01
      • 2020-08-17
      • 1970-01-01
      • 2011-04-29
      相关资源
      最近更新 更多