HbuilderX浏览器运行时出现404报错

新建server.js文件,将如下代码粘贴至文件中,然后将server.js替换至plugins/nodeserver下同名文件即可(替换完毕后请重启HX)。


```javascript
var args = process.argv.splice(2)[0];
var express = require('express');
var app = express();
var argsjson =JSON.parse(args); 
var projects = argsjson.projects;
var port = argsjson.port;

projects.forEach(function (value,index,array) {
	app.use('/'+encodeURI(value.name),express.static(value.path+''));
});

app.get('*', function(req, res){
    res.sendFile( __dirname + "/" + "404.html" );
});

var server = app.listen(port, function () {
	console.log('server start at '+port);
})


你可能感兴趣的:(javascript,vue.js,html,html5)