2016-07-17 7 views
3

Windows 10에 전자를 설치하려고하는데 작동하지 않습니다. 제 환경은 Windows 10, x64, 16GB RAM입니다. nodeJS 및 npm의 업데이트 된 버전을 설치했습니다.Windows 10에 전자를 설치하는 방법

내 응용 프로그램 루트 폴더 디렉토리가 C : \ nodeP \ APP1 와 나는 cmd를

  1. CD \
  2. CD nodeP
  3. CD를 APP1
  4. 에서 명령 다음 시도 npm init
  5. npm install 전자 사전 작성 - 저장 dev
  6. NPM은

main.js는

var app = require('app'); 
var BrowserWindow = require('browser-window'); 

app.on('ready', function() { 
    var mainWindow = new BrowserWindow({ 
    width : 500, 
    height : 200 
    }); 
}); 

파일 시작하지만 응용 프로그램을 실행할 때 그것은 나에게이 이미지와 같은 오류를 보여줍니다.

image

나는 MAC 및 Linux에 대한 모든 튜토리얼을 발견 창 (10) 저를 안내 할 수있는 인터넷의 모든 솔루션을 찾을 수 없습니다.

이 전자 응용 프로그램이 이러한 플랫폼에서만 사용되는지 여부를 알아야합니다. Windows 10을 지원한다면 저를 도우십시오.

답변

2

Node.JS 및 npm 업데이트를 설치해야합니다.

main.js

const electron = require('electron'); 
// Module to control application life. 
const {app} = electron; 
// Module to create native browser window. 
const {BrowserWindow} = electron; 

// Keep a global reference of the window object, if you don't, the window will 
// be closed automatically when the JavaScript object is garbage collected. 
let win; 

function createWindow() { 
    // Create the browser window. 
    win = new BrowserWindow({width: 800, height: 600}); 

    // and load the index.html of the app. 
    win.loadURL(`file://${__dirname}/index.html`); 

    // Open the DevTools. 
    win.webContents.openDevTools(); 

    // Emitted when the window is closed. 
    win.on('closed',() => { 
    // Dereference the window object, usually you would store windows 
    // in an array if your app supports multi windows, this is the time 
    // when you should delete the corresponding element. 
    win = null; 
    }); 
} 

// This method will be called when Electron has finished 
// initialization and is ready to create browser windows. 
// Some APIs can only be used after this event occurs. 
app.on('ready', createWindow); 

// Quit when all windows are closed. 
app.on('window-all-closed',() => { 
    // On macOS it is common for applications and their menu bar 
    // to stay active until the user quits explicitly with Cmd + Q 
    if (process.platform !== 'darwin') { 
    app.quit(); 
    } 
}); 

app.on('activate',() => { 
    // On macOS it's common to re-create a window in the app when the 
    // dock icon is clicked and there are no other windows open. 
    if (win === null) { 
    createWindow(); 
    } 
}); 

// In this file you can include the rest of your app's specific main process 
// code. You can also put them in separate files and require them here. 
<!DOCTYPE html> 
<html> 
    <head> 
    <meta charset="UTF-8"> 
    <title>Hello World!</title> 
    </head> 
    <body> 
    <h1>Hello World!</h1> 
    We are using node <script>document.write(process.versions.node)</script>, 
    Chrome <script>document.write(process.versions.chrome)</script>, 
    and Electron <script>document.write(process.versions.electron)</script>. 
    </body> 
</html> 

이 코드는하지

{ 
    "name": "app3", 
    "version": "1.0.0", 
    "description": "", 
    "main": "index.js", 
    "scripts": { 
    "start": "./node_modules/.bin/electron ." 
    }, 
    "author": "", 
    "license": "ISC", 
    "devDependencies": { 
    "electron-prebuilt": "^1.2.7" 
    } 
} 

마지막으로 내가 대답을 발견하고이 해결 다른 기능인 자바 스크립트를 파일 내부의 package.json 안에 있어야합니다 내 문제 Solution

+0

나를 위해 중요한 건 package.json 콘텐츠였습니다. 스크립트 가치는 나를 위해 모든 것이 작용했습니다. –

1

단계 5는 here과 같이 'save dev'가 포함되어야하며 'save dev'는 포함되지 않아야한다고 생각합니다.

또한 2011 년 7 월 17 일부터 전자 사전 이름 deprecated이 대신 전자 대신 사용되어야한다고 생각합니다. 내가 테스트 응용 프로그램을 만들 때

그러나, 완전한 전자 및 노드 newb로, 기술 및 '전자 TEST1'와 윈도우 10에서 PowerShell을에서 그것을 실행하려고, 나는 얻을이 :

용어 'Electron'은 cmdlet, 함수, 스크립트 파일 또는 작동 가능 프로그램의 이름으로 인식되지 않습니다.[추가]

하면 {프로젝트}에 내가 CD를 \ node_modules \ 전자 DIST의 \, 나는 다음 전자 자체 실행하려면이 작업을 수행 할 수 있습니다 \.

\ electron.exe

...하지만 그것은 내가 본 모든 문서에 주어진 짧은 형식보다 훨씬 어색합니다.

또한 main.js 파일을 일렉트론 앱으로 드래그 할 수있는 테스트 응용 프로그램을 실행하지 않지만, 내가 본 모든 단계별 방법보다 더 어색합니다.

내가 잘못 알고있는 부분이 있으면 알려주십시오.

관련 문제