Maison > Questions et réponses > le corps du texte
server.js是这样的,有写错吗??
const http = require('http')
const path = require('path')
const express = require('express')
const app = express();
const resolve = file => path.resolve(__dirname, file)
app.use('/dist', express.static(resolve('./dist')))
const zhihuPath= 'http://news-at.zhihu.com/api/4/'
function crawlerList(mes) {
var url = zhihuPath + mes;
return new Promise(function(resolve, reject) {
http.get(url,function(res) {
var html = "";
res.on('data', function(data) {
html += data;
})
res.on('end', function() {
resolve(html);
})
}).on('error', function(err) {
reject(err)
})
})
}
app.get('/',function(req, res) {
res.sendFile('index.html',{root:__dirname},function(err) {
if(err) {
console.log(err)
}else {
console.log('yes');
}
});
})
app.listen(18080,function() {
console.log('example app listening at 18080');
})
package.json
{
"dependencies": {
"express": "^4.14.0",
}
}
是因为我用了express,所以导致发布失败吗??
node_modules
目录需要自己上传吗?express
需要自己下载到node_modules
再上传吗??
https://cloud.baidu.com/doc/B...