素材牛VIP会员
用BAE发布node项目,是因为使用了express所以发布失败吗?
 飞***e  分类:Node.js  人气:898  回帖:1  发布于6年前 收藏

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...

 标签:node.js

讨论这个帖子(1)垃圾回帖将一律封号处理……

Lv1 新人
in***ex 职业无 6年前#1
 文明上网,理性发言!   😉 阿里云幸运券,戳我领取