electron "Cannot find module 'dialog'", source: module.js (336)"

打算用electron的dialog api

谁知道, 按官方api

http://electron.atom.io/docs/v0.33.0/api/dialog/

https://github.com/atom/electron/blob/master/docs/api/remote.md

竟然报 Cannot find module 'dialog'

我一开始以为这是nodejs的模块(刚用node,不熟悉),然后就安装

npm install dialog

结果发现这个dialog跟官方文档中说的dialog不是一个,因为方法对不上

于是

npm uninstall dialog

然后再搜素搜索发现

要用remote模块

于是

这样就可以了

var remote = require('remote');
var dialog = remote.require('dialog');

  

原文地址:https://www.cnblogs.com/simoncook/p/4858163.html