1

I am new to node.js and Heroku. I have tried to run the very first example server.js from the nodebeginner book on Heroku. The code for server.js is

var http = require("http");
http.createServer(function(request, response) {
    response.writeHead(200, {"Content-Type": "text/plain"});
    response.write("Hello World");
    response.end();
}).listen(8888);

To deploy server.js on Heroku, I have modified the files provided on https://devcenter.heroku.com/articles/nodejs

Especially, I have changed the file package.json to

{
    {
        "name": "node-example",
        "version": "0.0.1",
        "dependencies": {
        "http": "0.10.x"      <=== changed this line 
    },
        "engines": {
        "node": "0.10.x",
        "npm": "1.2.x"
    }
}

However, when I run npm install the error message

npm WARN package.json node-example@0.0.1 No repository field.
npm WARN package.json node-example@0.0.1 No readme data.
npm http GET https://registry.npmjs.org/http
npm http 404 https://registry.npmjs.org/http
npm ERR! 404 'http' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, or http url, or git url.
npm ERR! System Linux 3.2.0-40-virtual
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! cwd /home/ubuntu/nodebeginner
npm ERR! node -v v0.10.12
npm ERR! npm -v 1.2.32
npm ERR! code E404

So, how should I install the package "http" http://nodejs.org/api/http.html#http_http so I can use it on Heroku? Thanks a lot!

4

1 回答 1

1

您不需要将http依赖项添加到package.json文件中——它已经是 node.js 的一部分。

于 2013-07-12T21:36:39.393 回答