我是node.js和Heroku的新手。我试图从Heroku上的nodebeginner书中运行第一个示例server.js。 server.js的代码是
var http = require("http");
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}).listen(8888);
要在Heroku上部署server.js,我修改了提供的文件 https://devcenter.heroku.com/articles/nodejs
特别是,我已将文件package.json更改为
{
{
"name": "node-example",
"version": "0.0.1",
"dependencies": {
"http": "0.10.x" <=== changed this line
},
"engines": {
"node": "0.10.x",
"npm": "1.2.x"
}
}
但是,当我运行npm时安装错误消息
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
那么,我该如何安装软件包“http”http://nodejs.org/api/http.html#http_http 所以我可以在Heroku上使用它?非常感谢!
答案 0 :(得分:1)
您不需要将http
依赖项添加到package.json
文件中 - 它已经是节点的一部分。