How to run Express on io.js

爷,独闯天下 提交于 2019-12-08 10:47:31

问题


So Node.js was forked late last year and the forked version is io.js.

I can't find anything of a setup guide on the docs. I'm fairly new, anyone know how I can setup io.js using Express web framework? Thanks!


回答1:


Actually io.js wasn't released yet. First release will be at January 13th(or 14rth) (see here). At this time the best you can do to setup io.js is to clone its repository:

git clone https://github.com/iojs/io.js

and try to build it manually. On Unix/Max it looks like:

./configure
make
make install

But I do not recommend you to do this. Beware: now very active preparation for the first release is going on. Lots of commits with possibly breaking changes. So better wait less then one week until first official io.js version will be released.




回答2:


Do the steps in answer 1, then create an index.js file like this

var express = require('express');
var app = express();

app.use('/resources', express.static(__dirname + '/resources'));

app.get('*', function (req, res, next) {
    res.send('hello world');
    res.end();
});

app.listen(3000);

and a package.json file like this

{
  "name": "iojsexpress",
  "version": "0.0.0",
  "description": "Get express working with iojs",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.10.7"
  }
}

and then run the following commands

npm install
iojs index.js

and visit localhost port 3000 in your browser and you should see "hello world"



来源:https://stackoverflow.com/questions/27871309/how-to-run-express-on-io-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!