TypeScript getting error TS2304: cannot find name ' require'

后端 未结 23 2577
Happy的楠姐
Happy的楠姐 2020-11-22 06:00

I am trying to get my first TypeScript and DefinitelyTyped Node.js application up and running, and running into some errors.

I am getting the error \"TS2304: Cannot

23条回答
  •  孤街浪徒
    2020-11-22 06:32

    I've yet another answer that builds upon all previous ones that describe npm install @types/node and including node in tsconfig.json / compilerOptions / types.

    In my case, I have a base tsConfig.json and a separate one in the Angular application that extends this one:

    {
        "extends": "../../tsconfig.json",
        "compilerOptions": {
            "outDir": "../out-tsc/app",
            "types": []
     },
    

    My problem was the empty types in this tsconfi.app.json - it clobbers the one in the base configuration.

提交回复
热议问题