我正在尝试使用nw.js浏览器运行我的exe。我从这个链接https://github.com/nwjs/nw.js下载了nw.js然后我创建了这样的package.json文件:
{
"name": "sample",
"version": "1.0.0",
"description": "",
"main": "index.html",
"window": {
"toolbar": false,
"frame": false,
"resizable": false,
"show": true,
"kiosk": true,
"title": "kiosk example"
},
"webkit": {
"plugin": true
},
"chromium-args": "--ppapi-flash-path=plugins/libpepflashplayer.so --ppapi-flash-version=17.0.0.134",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "rohan",
"license": "ISC",
"dependencies": {
"express": "^4.13.3",
"gulp": "^3.9.0",
"nw-flash-trust": "^0.3.0"
}
}
我的index.html就像这样
<html>
<head>
<script>
function RunExe()
{
var child_process = require('child_process')
, exec = child_process.exec
, execSync = child_process.execSync
, execFile = child_process.execFile
, execFileSync = child_process.execFileSync
;
exec('quiz.exe');
}
</script>
</head>
<body>
<h1>Run a Program</h1>
This script launch the file any Exe File<p>
<button onclick="RunExe()">Run Exe File</button>
</body>
</html>
我将quiz.exe放在存在nw.exe的同一文件夹中但是当我的index.html页面加载并且我点击“运行exe文件”按钮时没有任何反应。我检查了控制台,它显示此错误消息:“未捕获的ReferenceError:require未定义”。我做错了什么?