本文介绍了环境变量中的Watson Conversation_Error的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从GitHub复制Watson对话简单节点js应用程序( https://github.com/watson-developer-cloud/conversation-simple )并在我的本地环境中运行.我已经创建了服务密钥和设置工作区.接下来,我更新了工作区ID,用户ID和& .env,app.js文件中的密码.我仅导入了现有的car_workspace.json文件,并使用了相应的工作区ID.在本地主机上运行时,我得到该应用尚未配置环境变量".请帮助我了解我是否有任何遗漏.

解决方案

尝试使用.env文件,并确保=和行尾之间没有空格.

您需要有一个名为.env的文件,在IBM Developers的项目中有一个示例,只需删除单词:example,然后该文件将在目录中仅用.env进行调用,如下图: /p>

并用您的服务凭据和Workspace_id替换这些值

# Environment variables
WORKSPACE_ID=490a9b3b-xxxxxxxxxxxxx
CONVERSATION_USERNAME=xxxxxxxxxxxxxx-e1ebbc10
CONVERSATION_PASSWORD=Bxxxx6FdzXxL

检查其他格式:

USERNAME="yourUsername"

在您的app.js中:

var workspace = process.env.WORKSPACE_ID || '<workspace-id>';
console.log(process.env.WORKSPACE_ID);//your value will appear

如果需要,可以使用另一种形式,可以设置 workspace_id 用户名密码在您的 app.js 文件中.

var username = 'usernameServiceCredentials'
var password = 'passwordServiceCredentials'
var workspace_id = 'workspaceFromConversation'

  • 有关更多信息,请参见 dotenv 文档.
  • 您可以在工作区->部署->凭据
  • 中看到您的凭据

I am trying to copy Watson conversation simple node js application from GitHub (https://github.com/watson-developer-cloud/conversation-simple) and running in my local.I have created service key and setup workspace. Next I have updated Workspace ID, User ID & Password in .env, app.js file. I have imported existing car_workspace.json file only and used corresponding Workspace ID.While running in local host I am getting "The app has not been configured with a environment variable."Please help me to understand if I am missing anything.

解决方案

Try to use the .env file and make sure the are no spaces between = and the end of the line.

You need to have one file called .env, within the project from IBM Developers has one example, just delete the word: example, and the file will called just with .env in your Directory, like this image:

And replace the values with your Service Credentials and your Workspace_id

# Environment variables
WORKSPACE_ID=490a9b3b-xxxxxxxxxxxxx
CONVERSATION_USERNAME=xxxxxxxxxxxxxx-e1ebbc10
CONVERSATION_PASSWORD=Bxxxx6FdzXxL

Check another format:

USERNAME="yourUsername"

And in your app.js:

var workspace = process.env.WORKSPACE_ID || '<workspace-id>';
console.log(process.env.WORKSPACE_ID);//your value will appear

If you want, has another form, you can set the workspace_id and username, password in your app.js file.

var username = 'usernameServiceCredentials'
var password = 'passwordServiceCredentials'
var workspace_id = 'workspaceFromConversation'

  • See the dotenv documentation for more information.
  • You can see your Credentials inside your Workspace -> Deploy -> Credentials

这篇关于环境变量中的Watson Conversation_Error的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 11:52