Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Electron,nodejs:应用程序无法启动,无法在其中一个模块中找到应用程序。_Javascript_Node.js_Npm_Electron - Fatal编程技术网

Javascript Electron,nodejs:应用程序无法启动,无法在其中一个模块中找到应用程序。

Javascript Electron,nodejs:应用程序无法启动,无法在其中一个模块中找到应用程序。,javascript,node.js,npm,electron,Javascript,Node.js,Npm,Electron,我正在试用一个电子应用程序,它应该指向我们的网站,所以我正在试用其中一个教程。。不幸的是,当我启动应用程序时,出现以下错误: 错误日志: akshay@akshay-mint-desktop ~/electron_tutorial_one $ npm start > electron_tutorial_one@1.0.0 start /home/akshay/electron_tutorial_one > electron . App threw an error during

我正在试用一个电子应用程序,它应该指向我们的网站,所以我正在试用其中一个教程。。不幸的是,当我启动应用程序时,出现以下错误:

错误日志:

akshay@akshay-mint-desktop ~/electron_tutorial_one $ npm start

> electron_tutorial_one@1.0.0 start /home/akshay/electron_tutorial_one
> electron .

App threw an error during load
Error: Cannot find module 'app'
    at Module._resolveFilename (module.js:455:15)
    at Function.Module._resolveFilename (/home/akshay/electron_tutorial_one/node_modules/electron-prebuilt/dist/resources/electron.asar/common/reset-search-paths.js:35:12)
    at Function.Module._load (module.js:403:25)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/akshay/electron_tutorial_one/index.js:2:11)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
A JavaScript error occurred in the main process
Uncaught Exception:
Error: Cannot find module 'app'
    at Module._resolveFilename (module.js:455:15)
    at Function.Module._resolveFilename (/home/akshay/electron_tutorial_one/node_modules/electron-prebuilt/dist/resources/electron.asar/common/reset-search-paths.js:35:12)
    at Function.Module._load (module.js:403:25)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/akshay/electron_tutorial_one/index.js:2:11)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
^Cakshay@akshay-mint-desktop ~/electron_tutorial_one $ 
package.json:

{
  "name": "electron_tutorial_one",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "electron ."
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "electron-prebuilt": "^1.4.13"
  }
}
而不是

//需要应用程序中使用的库
var app=require('app'),BrowserWindow=require('browser-window');
你应该使用

const{app,BrowserWindow}=require('electron'))

你用了一个很老的例子。两年多前,电子模块在
'Electron'
下收集;)

从发行说明:

添加包含所有公共API的electron模块

您最好使用电子文档中的教程:


什么是
require('app')
应该做什么?它是npm模块吗?或者其他地方的文件?@evolutionxbox:我对这一点不熟悉,但据我所知,它在上面给出的index.js中。
var-app=require('app')
这表示“我需要
app
”。从您所写的内容来看,它并不存在。@evolutionxbox:它是index.js:var app=require('app')中的第二行,
app
electron
的属性。所以你需要不同的方法,
var-electron=require('electron');var app=electron.app
{
  "name": "electron_tutorial_one",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "electron ."
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "electron-prebuilt": "^1.4.13"
  }
}