2016-08-23 60 views
0

如何獲取node.js來運行react.js前端?如何使用node.js運行react.js前端?

server.js

var express = require('express'); 
    var path = require('path'); 
    var logger = require('morgan'); 
    var cookieParser = require('cookie-parser'); 
    var bodyParser = require('body-parser'); 
    var mongoose = require('mongoose'); 
    var bcrypt = require('bcryptjs'); 


    var app = express(); 


    // links the node server to the webpage 
    app.use(express.static(path.join(__dirname, '../public'))); 



    app.set('port', process.env.PORT || 3000); 
    app.use(logger('dev')); 
    app.use(bodyParser.json()); 
    app.use(bodyParser.urlencoded()); 
    app.use(cookieParser()); 

    app.listen(app.get('port'), function() { 
    console.log('Express server listening on port ' + app.get('port')); 
    }); 

運行此代碼我angularjs網站不錯,但做什麼樣的變化我必須做出它運行正在使用的WebPack + ES6的react.js?

回答

相關問題