2016-12-11 10 views
0

私は今日電子で始まり、簡単なアプリケーションブラウザウィンドウを作成するためのガイドに従っています。コマンドウィンドウでnpm startを実行しました。入力した後で多くのエラーが表示されました。 。"npm start"を実行しているときにエラーが発生しましたか?

コンソールエラー:

C:\Users\Administrator\Desktop\electron>npm start 

> [email protected] start C:\Users\Administrator\Desktop\electron 
> node index.js 

module.js:471 
    throw err; 
    ^

Error: Cannot find module 'app' 
    at Function.Module._resolveFilename (module.js:469:15) 
    at Function.Module._load (module.js:417:25) 
    at Module.require (module.js:497:17) 
    at require (internal/module.js:20:19) 
    at Object.<anonymous> (C:\Users\Administrator\Desktop\electron\index.js:1:73) 
    at Module._compile (module.js:570:32) 
    at Object.Module._extensions..js (module.js:579:10) 
    at Module.load (module.js:487:32) 
    at tryModuleLoad (module.js:446:12) 
    at Function.Module._load (module.js:438:3) 

npm ERR! Windows_NT 10.0.14393 
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start" 
npm ERR! node v6.9.2 
npm ERR! npm v3.10.9 
npm ERR! code ELIFECYCLE 
npm ERR! [email protected] start: `node index.js` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the [email protected] start script 'node index.js'. 
npm ERR! Make sure you have the latest version of node.js and npm installed. 
npm ERR! If you do, this is most likely a problem with the breef package, 
npm ERR! not with npm itself. 
npm ERR! Tell the author that this fails on your system: 
npm ERR!  node index.js 
npm ERR! You can get information on how to open an issue for this project with: 
npm ERR!  npm bugs breef 
npm ERR! Or if that isn't available, you can get their info via: 
npm ERR!  npm owner ls breef 
npm ERR! There is likely additional logging output above. 

npm ERR! Please include the following file with any support request: 
npm ERR!  C:\Users\Administrator\Desktop\electron\npm-debug.log 

ここでは私のpackage.jsonである:ここでは

{ 
    "name": "breef", 
    "version": "1.0.0", 
    "description": "A simple chat application.", 
    "main": "index.js", 
    "dependencies": { 
    "electron": "^1.4.12" 
    }, 
    "devDependencies": {}, 
    "scripts": { 
    "test": "breeftestcmd", 
    "start": "node index.js" 
    }, 
    "keywords": [ 
    "breef" 
    ], 
    "author": "Sage & Sh4wn", 
    "license": "ISC" 
} 

は私のindex.jsです:

var app = require("app") 
var browserWindow = require("browser-window") 

app.on('ready', function() { 
    var mainWindow = new browserWindow({ 
     width: 800, 
     height: 600 
    }) 

    mainWindow.loadUrl('http://google.com'); 
}) 
+0

です '' node_modules'たり、プロジェクト内の他のファイル内のモジュールをapp'?プロジェクトのモジュールを要求するには、パスは '/'、 '。/'、 '../'(https://nodejs.org/dist/latest-v7.x/docs/api/で始まる必要があります。 modules.html#modules_file_modules) - たとえば'require(" ./app ")'です。 "*/'、' ./ '、または' ../ 'のように先頭にファイルがない場合、モジュールはコアモジュールであるか、node_modulesフォルダからロードされている必要があります。*" –

答えて

0

アプリがモジュールである場合は、それが欠けていますあなたのpackage.jsonで。そうでない場合、あなたはそれが

var app = require('./app'); 
0

あなたが続いガイドは電子のよう内蔵の電子モジュールが変更されたインポートする方法をV1.0.0、期限が切れて要求するようにパスを使用する必要があります。これが正しい方法です:

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

ます。また、それは有益なこのトピックをカバーし、前の質問を読むために見つけることがあります。What's the proper way to require in Node.js?

関連する問題