DATABASE_URL未定义node.js

时间:2015-06-25 23:11:20

标签: node.js

我在仪表板中配置了DATABASE_URL。 当我在我的提示heroku配置

我明白了:

miguel@miguel-VirtualBox:~/Escritorio/mis_proyectos/quiz$ heroku config
=== quiz-miguel2015 Config Vars
DATABASE_URL:               postgres://fudidvccwppmri:Ki28zZ00ikrE43UBcKT1YnQLwb@ec2-54-83-18-87.compute-1.amazonaws.com:5432/d4fh6o7fu6cv5q
HEROKU_POSTGRESQL_GOLD_URL: postgres://fudidvccwppmri:Ki28zZ00ikrE43UBcKT1YnQLwb@ec2-54-83-18-87.compute-1.amazonaws.com:5432/d4fh6o7fu6cv5q
NODE_ENV:                   production

但我失败了:

undefined

/home/miguel/Escritorio/mis_proyectos/quiz/models/models.js:5
var url = process.env.DATABASE_URL.match(/(.*)\:\/\/(.*?)\:(.*)@(.*)\:(.*)\/(.
                                   ^
TypeError: Cannot call method 'match' of undefined
    at Object.<anonymous>

我收到fail models.js

的文件
var path = require('path');
// Postgres DATABASE_URL = postgres://user:passwd@host:port/database
// SQLite   DATABASE_URL = sqlite://:@:/
console.dir(process.env.DATABASE_URL);
var url = process.env.DATABASE_URL.match(/(.*)\:\/\/(.*?)\:(.*)@(.*)\:(.*)\/(.*)/);

我在根目录中创建了我的文件.env,其中包含以下值:

DATABASE_URL=sqlite://:@:/
DATABASE_STORAGE=quiz.sqlite

我在这里得到完整的日志:

TypeError: Cannot call method 'match' of undefined
    at Object.<anonymous> (/home/miguel/Escritorio/mis_proyectos/quiz/models/models.js:5:36)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/home/miguel/Escritorio/mis_proyectos/quiz/controllers/quiz_controller.js:2:14)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)

代码在=&gt; https://github.com/Mangulomx/Quiz

0 个答案:

没有答案