TypeScript getting error TS2304: cannot find name ' require'

后端 未结 23 2973
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条回答
  •  萌比男神i
    2020-11-22 06:39

    Electron + Angular 2/4 addition:

    On top of adding the 'node' type to ts.config various files, what eventually worked for me was adding the next to the typings.d.ts file:

    declare var window: Window;
    interface Window {
      process: any;
      require: any;
    }
    

    Note that my case is developing with Electron + Angular 2/4. I needed the require on the window global.

提交回复
热议问题