为什么我无法从VCAP_APPLICATION - 本地nodeJS服务器获取application_id

时间:2015-12-14 22:11:07

标签: node.js ibm-cloud

我使用“移动客户端访问”服务创建了一个Bluemix nodeJS应用。该应用程序在Bluemix中运行完美,但是当我将代码下载到笔记本电脑后尝试在本地运行时无法加载。看起来它需要访问一些env变量,该变量仅在Bluemix中可用,而不在我的本地环境中。我是否必须创建某种env文件才能在本地运行它?感谢您的帮助。

导致错误的代码:

var ImfBackendStrategy = require('passport-imf-token-validation').ImfBackendStrategy;
var imf = require('imf-oauth-user-sdk');
passport.use(new ImfBackendStrategy());

这是错误:

[ERROR] Can't get the application_id from VCAP_APPLICATION, please check if the application running on bluemix.
/Users/xxx/git/DigitalAgent/node_modules/passport-imf-token-validation/lib/imf-backend-strategy.js:31
    throw new TypeError(msg);
          ^
TypeError: Can't get the application_id from VCAP_APPLICATION, please check if the application running on bluemix.
at new Strategy (/Users/xxx/git/DigitalAgent/node_modules/passport-imf-token-validation/lib/imf-backend-strategy.js:31:9)
at Object.<anonymous> (/Users/xxx/git/DigitalAgent/app.js:14:14)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3

2 个答案:

答案 0 :(得分:0)

您必须在本地计算机上设置环境变量。您可以在仪表板控制台的左侧菜单中单击“环境变量”,在Bluemix上查看变量环境。

答案 1 :(得分:0)

我在使用bluemix入门代码时遇到了同样的问题,我在./server/server.js下面的一行注释并开始工作。

//passport.use(new MCABackendStrategy())