lenny lenny - 1 year ago 211
TypeScript Question

NW.js + TypeScript: Cannot find module 'nw.gui'

I am trying to use TypeScript in an existing NW.js + JS project.

Since I am new to NW.js, I naively assumed it works out of the box after installing the nw.gui typings.

It doesn't (as TypeScript does not recognize the global


import * as nw from 'nw.gui';

Gives me

Cannot find module 'nw.gui'

How do I setup my code to work properly with NW.js?

Answer Source

Workaround which lets me use the global nw variable from NW.js: declare var nw: any;

The compiler doesn't complain anymore. I don't get any type information, but I can live with that and just use it as I would in JS.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download