我有一个电子应用程序,当点击其中一个按钮时使用Nightmare.js。它在打包之前工作正常,但在我用电子打包器将它编译成.exe文件后,它会按预期工作,直到我点击使用Nightmare.js的按钮。我收到这个错误:
Uncaught Error: Cannot find module 'electron-prebuilt'
at Module._resolveFilename (module.js:470)
at Function.Module._resolveFilename (C:\app-directory\app-name-win32-ia32\resources\electron.asar\common\reset-search-paths.js:35)
at Function.Module._load (module.js:418)
at Module.require (module.js:498)
at require (internal/module.js:20)
at Object.<anonymous> (C:\app-directory\app-name-win32-ia32\resources\app\node_modules\nightmare\lib\nightmare.js:16)
at Object.<anonymous> (C:\app-directory\app-name-win32-ia32\resources\app\node_modules\nightmare\lib\nightmare.js:528)
at Module._compile (module.js:571)
at Object.Module._extensions..js (module.js:580)
at Module.load (module.js:488)
答案 0 :(得分:0)
确保已将electron-prebuilt
添加到package.json中的development dependency
。您可以按npm install --save-dev electron-prebuilt
在Electron中要求app模块的正确方法是:
const {app} = require('electron')
希望有所帮助。