同时运行React和Node。

我有一个用例,我不认为是太独特,但我遇到了挑战。 我的应用程序是用express / EJS编写的,运行在35端口上,我想包括反应,所以我正在学习一个教程,并在我现有的应用程序中编写这个应用程序,并在另一个端口上运行它。 我可以看到这两个应用程序,当他们在不同的端口,如果我试图把他们在他们冲突的同一端口。 咄。 不过,我想在我的应用程序中运行某些function的反应,我该如何做到这一点? 我如何运行我的节点应用程序,并在同一时间作出反应?

我的反应应用程序的依赖项是:

"babel": "^6.5.2", "babel-loader": "^6.2.10", "babel-preset-es2015": "^6.18.0", "babel-preset-react": "^6.16.0", "babel-preset-stage-2": "^6.18.0", "react": "^15.4.1", "react-dom": "^15.4.1", "webpack": "^1.14.0", "webpack-dev-server": "^1.16.2" 

我的整个依赖树是

  "dependencies": { "async": "^2.1.4", "babel": "^6.5.2", "babel-loader": "^6.2.10", "babel-preset-es2015": "^6.18.0", "babel-preset-react": "^6.16.0", "babel-preset-stage-2": "^6.18.0", "bcrypt-nodejs": "0.0.3", "bluebird": "^3.4.6", "body-parser": "^1.15.2", "cloudinary": "^1.4.6", "cookie-parser": "^1.4.3", "ejs": "^2.5.2", "express": "^4.14.0", "express-flash": "0.0.2", "express-session": "^1.14.2", "method-override": "^2.3.7", "moment": "^2.17.0", "mongoose": "^4.6.8", "morgan": "^1.7.0", "multer": "^1.2.0", "nodemailer": "^2.7.0", "passport-local-mongoose": "^4.0.0", "react": "^15.4.1", "react-dom": "^15.4.1", "serve-favicon": "^2.3.2", "webpack": "^1.14.0", "webpack-dev-server": "^1.16.2", "xoauth2": "^1.2.0" }, 

顶部列表只是我加载的教程。 所以也许在Node中运行React不需要Web服务器方面的反应,如果有的话? 还是只是使用节点?

这是webpack.config.js文件。

 const webpack =require('webpack'), path =require('path'); const DIST_DIR = path.resolve(__dirname, "dist"); const SRC_DIR = path.resolve(__dirname, "src"); const config = { entry: SRC_DIR + "/app/index.js", output: { path: DIST_DIR + "/app", filename: "bundle.js", publicPath: "/app/" }, module: { loaders: [ { test: /\.js?/, include: SRC_DIR, loader: "babel-loader", query: { presets: ["react", "es2015", "stage-2"] } } ] } }; module.exports = config; 

这是pacakge.json文件中的脚本。 这有代码与端口等:

  "scripts": { "start":"npm run build", "build":"webpack -d && sudo cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --hot --host 0.0.0.0 --port 35", "build:prod": "webpack -p && cp src/index.html dist/index.html" },