@RogerWang 你好,想跟你请教个问题:
@newwell 你好,想跟你请教个问题:我想用nwjs nwjs-v0.15.0-win-x64,进行程序发布,但是总是不成功(现象为只启了4个进程,没有弹出nw浏览器)。同样的配置和方法在v0.12.3可以。您能帮解答下吗?
<p style="font-size:13.3333330154419px;">
方法为:
</p>
<p style="font-size:13.3333330154419px;">
1.在<span style="font-size:13.3333330154419px;">nwjs-v0.15.0-win-x64文件夹下建我的程序包 testapp,里面放程序包,app.js,package.json(他两个在跟目录),</span>
</p>
<p style="font-size:13.3333330154419px;">
<span style="font-size:13.3333330154419px;">2.在<span style="font-size:13.3333330154419px;">nwjs-v0.15.0-win-x64下和nw.exe同级放package.json,为nw.exe 创建快捷方式,并且在快捷路径后添加我的 testapp。</span></span>
</p>
<p style="font-size:13.3333330154419px;">
文件结构布局如图<img src="https://static.oschina.net/uploads/space/2016/0920/173335_OYdT_2920029.png" alt="">
</p>
package.json
{
"name": "测试系统",
"nodejs": true,
"node-main": "app.js",
"main": "http://127.0.0.1:8999/js/LogOnPage/",
"window": {
"title": "测试系统",
"toolbar": false,
"show": false,
"icon":"logo.ico"
}
}
app.js为程序入口 内容为
var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');
var io = require("socket.io");
var routes = require('./routes/index');
var dacRoute = require('./routes/routeDac');
var app = express();
var logger = require("./app/Log.js");
var express_session = require('express-session');
var cookieParser = require('cookie-parser');
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'public')));
app.use(cookieParser());
app.use(express_session({
secret:'12345',
name:'test',
cookie:{
maxAge:''//60000
},
resave:false,
saveUninitialized:true
}));
console.log(__dirname);
app.use(routes);
app.use(dacRoute);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
// error handlers
// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: err
});
});
}
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: {}
});
});
//数据库初始化
var dac =require('./app/DacServer.js');
dac.initDacInfo();
var ServerCache =require('./app/SeverCache');
ServerCache.GetInfo();//服务端初始化读库
var socketServerCommu = require('./app/SocketServerCommu');
var io = require('socket.io')();
io.listen(9999);
io.on('connection', function(socket){
console.log("客户端请求建立websocket连接");
socketServerCommu.processMsgFromWebClient(socket);
});
logger.info('准备监听端口------------------------');
//访问路测仪 win7下administrator访问网络共享有问题,提前加入到net use里
var batProcess = require('child_process');
batProcess.exec('net use \\192.168.0.1 "lcy" /user:"lcy"',function(err){
if(err) {
console.log(err);
}
});
var server = app.listen(8999,'127.0.0.1',function(err){
logger.info('启动了------------------------');
logger.info(err);
});
process.on('uncaughtException',function(err){
logger.info('报错了------------------------');
console.log('报错了------------------------');
logger.info(err);
console.log(err);
});
module.exports = app;
http://www.cnblogs.com/2050/p/3543011.html
我一直用的是这种方法,你可以试试
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。