【问题标题】:Electron-Typescript app crashes due to moduleElectron-Typescript 应用程序由于模块而崩溃
【发布时间】:2022-08-02 13:43:46
【问题描述】:

我正在尝试使用 Typescript 构建在 Electron 上运行的客户端,但是,我收到以下错误:

tsconfig.json 如下:

{
  \"compilerOptions\": {
    \"target\": \"es5\",
    \"lib\": [
      \"dom\",
      \"dom.iterable\",
      \"esnext\"
    ],
    \"allowJs\": true,
    \"skipLibCheck\": true,
    \"esModuleInterop\": true,
    \"allowSyntheticDefaultImports\": true,
    \"strict\": true,
    \"useUnknownInCatchVariables\": false,
    \"forceConsistentCasingInFileNames\": true,
    \"noFallthroughCasesInSwitch\": true,
    \"module\": \"esnext\",
    \"moduleResolution\": \"node\",
    \"resolveJsonModule\": true,
    \"isolatedModules\": true,
    \"noEmit\": true,
    \"typeRoots\": [
      \"node_modules/@types\",
      \"src/types\"
    ],
    \"jsx\": \"react-jsx\"
  },
  \"include\": [
    \"src\"
  ]
}

package.json 是这样的:

{
  \"name\": \"electron-quick-start-typescript\",
  \"version\": \"1.0.0\",
  \"description\": \"A minimal Electron application written with Typescript\",
  \"scripts\": {
    \"build\": \"tsc\",
    \"watch\": \"tsc -w\",
    \"lint\": \"eslint -c .eslintrc --ext .ts ./src\",
    \"start\": \"npm run build && electron --no-sandbox ./dist/main.js\"
  },
  \"type\": \"module\",
  \"repository\": \"https://github.com/electron/electron-quick-start-typescript\",
  \"keywords\": [
    \"Electron\",
    \"quick\",
    \"start\",
    \"tutorial\",
    \"demo\",
    \"typescript\"
  ],
  \"author\": \"GitHub\",
  \"license\": \"CC0-1.0\",
  \"devDependencies\": {
    \"@types/axios\": \"^0.14.0\",
    \"@types/electron\": \"^1.6.10\",
    \"@types/jquery\": \"^3.5.14\",
    \"@types/node\": \"^17.0.42\",
    \"@typescript-eslint/eslint-plugin\": \"^4.33.0\",
    \"@typescript-eslint/parser\": \"^4.33.0\",
    \"electron\": \"^18.2.3\",
    \"eslint\": \"^7.32.0\",
    \"typescript\": \"^4.7.2\"
  },
  \"dependencies\": {
    \"axios\": \"^0.27.2\",
    \"jquery\": \"^3.6.0\"
  }
}

无论我在tsconfig 中选择什么模块类型,我都遇到了错误.任何提示表示赞赏。提前致谢。

    标签: typescript electron


    【解决方案1】:

    尝试使用“模块”:“commonjs”在 tsconfig,json 和删除“类型”:“模块”来自 package.json

    【讨论】:

      猜你喜欢
      • 2020-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-05
      • 2014-03-30
      • 1970-01-01
      • 2019-05-16
      • 2021-04-20
      相关资源
      最近更新 更多