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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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