Tag: heroku

将缓冲区转换为Redis中的string获取Node.js Heroku应用程序

这是我非常基本的GETfunction app.get('/', function(request, response) { response.contentType('application/json'); var lid = request.param("lid"); client.llen(lid, function(reply, len){ client.lrange(lid, 0, len-1, function(reply, messages){ console.log(messages); response.send(messages); }) }); }); 出于某种原因,控制台输出和我得到的响应看起来像 [ <Buffer 5b 7b 22 6c 61 77 79 65 72 5f … 61 64 61 74 61 22 3a 22 36 22 7d 5d> ] 我将这些存储为JSONstring: client.lpush(lid, JSON.stringify(to_store)) 任何想法,为什么我的回应不是一个JSONstring? 谢谢。

有一个程序化的方式来了解node.js应用程序在Heroku中运行吗?

是否有一些variables或函数,我可以打电话来知道一个node.js应用程序在Heroku中运行? 就像是: if (process.heroku) console.log("I'm in Heroku!");

无法在Heroku上成功执行Node.js应用程序(每次崩溃)

我试图把Heroku上的一个示例node.js应用程序放在一起,基本上按照他们的说明在这里: https : //devcenter.heroku.com/articles/nodejs 该应用程序运行良好,本地foreman start ,但是,每次我部署应用程序崩溃。 我究竟做错了什么? 我的Procfile包含: web: node web.js 我的package.json包含: { "name": "testapp", "version": "0.0.1", "engines": { "node": "0.6.15" , "npm": "1.1.9" } , "dependencies": { "tower": "0.4.0-12" } } 我的web.js包含: var express = require('express'); var app = express.createServer(express.logger()); app.get('/', function(request, response) { response.send('Hello World!'); }); var port = process.env.PORT || 3000; […]

无法在Heroku上部署Hubot

我在上个月(2月13日)用hubot 2.4.6在Heroku上部署了一个Hubot实例。 今天,我想添加一个新的脚本,并得到一个编译错误,当部署回heroku。 更新之前,我尝试部署一个新的新hubot维基百科指令导致完全相同的错误,这里是日志: $ git push heroku master Counting objects: 23, done. Delta compression using up to 8 threads. Compressing objects: 100% (19/19), done. Writing objects: 100% (23/23), 10.58 KiB, done. Total 23 (delta 0), reused 0 (delta 0) —–> Node.js app detected —–> Resolving engine versions Using Node.js version: 0.10.0 Using npm version: […]

无法读取heroku中保存的文件

我在heroku上使用NodeJS。 我从另一台服务器读取一个文件,并将其保存到/ temp目录中的应用程序中。 接下来,我读取相同的文件传递给我的客户端。 保存文件,然后读取它的代码是: http.request(options, function (pdfResponse) { var filename = Math.random().toString(36).slice(2) + '.pdf', filepath = nodePath.join(process.cwd(),'temp/' + filename); pdfResponse.on('end', function () { fs.readFile(filepath, function (err, contents) { //Stuff to do after reading }); }); //Read the response and save it directly into a file pdfResponse.pipe(fs.createWriteStream(filepath)); }); 这在我的本地主机上运行良好。 但是,在部署到heroku时,出现以下错误: events.js:72 throw er; // Unhandled […]

尝试呈现i帧:祖先违反了以下内容安全策略指令:“frame-ancestors'none'”

我想呈现一个iframe的来源是Github像这样: <iframe src="https://gist.github.com/user45445/9bf8d568e3350146ba302d7d67ad576f"> </iframe> 这是我在控制台中得到的错误: Refused to display 'https://gist.github.com/fresh5447/9bf8d568e3350146ba302d7d67ad576f' in a frame because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'none'". 我正在研究如何在我的Node服务器中指定我的Content Security Policy ,指定它应该接受来自github任何iframe 所以我安装了csp-helmet,并将其添加到我的服务器代码中: var csp = require('helmet-csp') app.use(csp({ // Specify directives as normal. directives: { frameAncestors: ['*.github.com'], //I thought these two did the same, so I tried them both. […]

Node.js /socket.io/socket.io.js找不到4.0

所以我试图让聊天工作在我的网站上,当我在本地testing时,它工作得很好,因为我的本地主机上的端口8080是可用的,所有的好东西。 但现在我把我的代码推送到我的Heroku应用程序,当我尝试加载我的聊天页面时,出现错误,指出无法获取localhost:8080 / socket.io / socket.io.js。 我看到node.js /socket.io/socket.io.js没有find,并试图build议,但没有工作,即使将socket.io.js文件移动到资源文件不起作用。 我猜这是因为我使用Express 4.0? 任何帮助,将不胜感激 编辑:所以要添加更多的细节,因为我的问题可能看起来有点模糊,这里是我的相关app.js代码: var client = require('socket.io').listen(8080).sockets; 在我的聊天页面的玉文件中,我有: script (src = `'http://localhost:8080/socket.io/socket.io.js`') 并在稍后 var socket = io.connect(`'http://localhost:8080`'); 所有这一切工作本地主机(我加载在端口5000,socket.io连接到端口8080)。 我使用heroku toolbelt使用“工头”开始工作。 当我尝试改变这些工作在heroku,它打破了,我不知道如何解决它。 我希望这个问题稍微澄清一点。 编辑2:我正在运行:express 4.0.0 socket.io 0.9.16 节点0.10.x 谢谢

无法使用Bash&NPMreplaceconfiguration中的env

我正在尝试在我的应用程序中使用私有NPM模块,并且需要设置适当的NPM访问令牌,以便第三方工具(Heroku和CI)可以访问并安装该模块。 我在~/.bash_profile设置了以下行: export NPM_TOKEN="XXXXX-XXXXX-XXXXX-XXXXX" 然后在/path/to/app/.npmrc我有 //registry.npmjs.org/:_authToken=${NPM_TOKEN} 但是,每当我打开我的terminal,我在启动时出现以下错误: Error: Failed to replace env in config: ${NPM_TOKEN} at /Users/marcthomas/.nvm/versions/node/v4.2.1/lib/node_modules/npm/lib/config/core.js:429:13 at String.replace (native) at envReplace (/Users/marcthomas/.nvm/versions/node/v4.2.1/lib/node_modules/npm/lib/config/core.js:424:12) at parseField (/Users/marcthomas/.nvm/versions/node/v4.2.1/lib/node_modules/npm/lib/config/core.js:400:7) at /Users/marcthomas/.nvm/versions/node/v4.2.1/lib/node_modules/npm/lib/config/core.js:338:17 at Array.forEach (native) at Conf.add (/Users/marcthomas/.nvm/versions/node/v4.2.1/lib/node_modules/npm/lib/config/core.js:337:23) at ConfigChain.addString (/Users/marcthomas/.nvm/versions/node/v4.2.1/lib/node_modules/npm/node_modules/config-chain/index.js:244:8) at Conf.<anonymous> (/Users/marcthomas/.nvm/versions/node/v4.2.1/lib/node_modules/npm/lib/config/core.js:325:10) at /Users/marcthomas/.nvm/versions/node/v4.2.1/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:76:16 /Users/marcthomas/.nvm/versions/node/v4.2.1/lib/node_modules/npm/lib/npm.js:29 throw new Error('npm.load() required') ^ Error: npm.load() required at Object.npm.config.get (/Users/marcthomas/.nvm/versions/node/v4.2.1/lib/node_modules/npm/lib/npm.js:29:11) at […]

Heroku创build命令产生“ENOENT”错误

当试图调用“heroku创build”时,我得到以下结果: Creating app… done, stack is cedar-14 ENOENT: spawn git ENOENT 我该如何解决这个错误?

如何在部署的Heroku NodeJS应用程序上运行npm脚本

在package.json scripts ,我有以下几点。 'refresh': node refresh db 有没有办法在部署在Heroku上的NodeJS应用程序上触发这个特定的npm脚本。