我有一个文件服务器可以在我的Rpi 2上使用Raspian完美运行,我一直在尝试使用Jesse将其迁移到更新的Rpi3。每次我尝试运行它时,我都会得到以下错误堆栈
/media/pi/DemoServer.js:82
server.listen(port, () => {
^
SyntaxError: Unexpected token )
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
有关为何发生这种情况的任何建议?我应该解决的两个发行版之间是否存在微妙的细微差别?
这是服务器的代码(有一些遗漏)。
const express = require('express');
const formidable = require('formidable');
const fs = require('fs-extra');
const http = require('http');
const util = require('util');
const serveIndex = require('serve-index');
const serveStatic = require('serve-static');
const path = require('path');
const server = express();
const port = process.env.PORT || 1001;
const dirToServe = '/media/pi/Shared';
function setHeaders(res, filepath) {
res.setHeader('Content-Disposition', 'attachment; filename=' + path.basename(filepath));
}
server.post('/media/pi/Shared', function(req,res) {
});
//Serve the static folder and the index of the folder
server.use('/', serveIndex(dirToServe, { icond: true }));
server.use('/', serveStatic(dirToServe, {setHeaders: setHeaders }));
server.listen(port, () => {
console.log('listening on port ' + port);
});