【问题标题】:How to run Express on io.js如何在 io.js 上运行 Express
【发布时间】:2015-01-10 00:08:39
【问题描述】:

所以 Node.js 是去年年底分叉的,分叉的版本是 io.js。

我在文档中找不到任何设置指南。我是新手,有人知道我如何使用 Express Web 框架设置 io.js 吗?谢谢!

【问题讨论】:

    标签: javascript express frameworks io.js


    【解决方案1】:

    执行答案1中的步骤,然后像这样创建一个index.js文件

    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);
    

    还有一个像这样的package.json 文件

    {
      "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"
      }
    }
    

    然后运行以下命令

    npm install
    iojs index.js
    

    并在浏览器中访问 localhost 端口 3000,您应该会看到“hello world”

    【讨论】:

      【解决方案2】:

      其实io.js 还没有发布。第一个版本将于 1 月 13 日(或 14 日)发布(请参阅here)。此时你可以做的最好的设置io.js是克隆它的repository

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

      并尝试手动构建它。在 Unix/Max 上它看起来像:

      ./configure
      make
      make install
      

      但我不建议您这样做。注意:现在正在为第一个版本进行非常积极的准备。大量提交可能会造成重大更改。所以最好等不到一个星期,直到第一个官方io.js 版本发布。

      【讨论】:

        猜你喜欢
        • 2011-10-28
        • 2018-09-19
        • 2021-06-11
        • 1970-01-01
        • 2015-09-08
        • 1970-01-01
        • 2016-02-06
        • 2015-01-07
        • 2021-03-21
        相关资源
        最近更新 更多