NodeJS pptxgenjs:此表达式不可构造

bwntbbo3  于 12个月前  发布在  Node.js
关注(0)|答案(1)|浏览(137)

我是NodeJS的新手。
我正在尝试为NodeJS应用程序编写以下代码(在src/index.ts中):

import pptxgenjs from 'pptxgenjs';
const pres = new pptxgenjs();

Source
但是Typescript编译器给了我以下错误:
此表达式不可构造。
类型“typeof import(“#/node_modules/pptxgenjs/types/index”)“没有构造签名。
我的tsconfig.json看起来像这样:

{
    "compilerOptions": {
        "module": "NodeNext",
        "moduleResolution": "NodeNext",
        "target": "ES2020",
        "sourceMap": true,
        "outDir": "dist",
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true
    },
    "include": ["src/**/*"]
}

我能做些什么来解决这个问题?

xzv2uavs

xzv2uavs1#

它看起来像我在一个typescript项目上使用完全相同的代码,它为我工作。

import pptxgen from "pptxgenjs";
let pres: pptxgen
pres = new pptxgen();

它位于NextJs typescript项目中。
下面是我的tslog.json文件的开头。希望这对你有帮助。

{
  "compilerOptions": {
    "baseUrl": ".",
    "target": "esnext",
    "module": "es2020",
    "lib": [
      "esnext",
      "dom"
    ],
    "jsx": "preserve",
    "moduleResolution": "node",
    "strict": true,
    "sourceMap": true,
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "noEmit": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "typeRoots": [
      "./node_modules/@types",
    ],
    "allowJs": true,
    "incremental": true,
    "isolatedModules": true,
    "plugins": [
      {
        "name": "next"
      }
    ]
  },

相关问题