webstorm node.js error does not occur when run from command line
using webstorm, I'm am using the howdy.ai slackbot sdk kit. I get and invalid_auth error. I set the token in the environment for webstorm. But from the command line this runs without error when I run
$token=xoxoTOKEN node attendbot.js
Is there some configuration setting that needs to be set differently, so that it more closely recreates the condition of the command line. Webstorm errors whether I set the interpreter to v7, v6.9 or v5
Thanks in advance.
Please sign in to leave a comment.
if $token is an environment variable that is read by your app, you need specifying it in your Node.js run configuration, Environment variables field
It is set as an environment variable in the configuration. Sorry that wasn't clear in my original post.
what does your configuration look like? Please provide a screenshot. Also, how do you access this variable in your code?
Here are images.
configuration:
Output with error:
$ token=xoxo-xxxxxxxxxxxxxxxxxx node slack_bot.js
Initializing Botkit v0.5.1
info: ** No persistent storage method specified! Data may be lost when process shuts down.
debug: Setting up a handler for spawned
debug: Setting up a handler for heard_trigger
debug: Setting up a handler for command_triggered
debug: Setting up a handler for remote_command_end
info: ** Setting up custom handlers for processing Slack messages
debug: Setting up a handler for message_received
debug: rtm.start { no_unreads: true,
simple_latest: true,
token: 'xoxb-xxxxxxxxxxxxxxxxxxxxxxxxxxxx' }
info: ** API CALL: https://slack.com/api/rtm.start
debug: Setting up a handler for direct_message
debug: Setting up a handler for direct_mention
debug: Setting up a handler for mention
debug: Setting up a handler for direct_message
debug: Setting up a handler for direct_mention
debug: Setting up a handler for mention
debug: Setting up a handler for direct_message
debug: Setting up a handler for direct_mention
debug: Setting up a handler for mention
debug: Setting up a handler for direct_message
debug: Setting up a handler for direct_mention
debug: Setting up a handler for mention
debug: Setting up a handler for direct_message
debug: Setting up a handler for direct_mention
debug: Setting up a handler for mention
debug: Got response null {"ok":true,"self":{"id":"U4HLW3BPV","name":"attendbot","prefs":{"highlight_words":"....\/\/mpmulti-e5oi.slack-msgs.com\/websocket\/jMSV3gqxuRGc2RcfBI90jltABqavhwRsvtoAzyeKCs3YYWGWtARkmREJAC0ws-n_KLR41-FfYYV9fZVeHuJgCElvkqT3XHCbdWgejbbwa_AK8Zf3d2qsQObtE4EKdstM0Wt3cowNh2BLsnzhyRyXeqRn4GI7oqJNcsxW7uVKXoY="}
notice: ** BOT ID: attendbot ...attempting to connect to RTM!
notice: RTM websocket opened
debug: RECEIVED MESSAGE
debug: CUSTOM FIND CONVO undefined undefined
debug: DEFAULT SLACK MSG RECEIVED RESPONDER
debug: RECEIVED MESSAGE
debug: CUSTOM FIND CONVO U4HLW3BPV undefined
debug: DEFAULT SLACK MSG RECEIVED RESPONDER
debug: RECEIVED MESSAGE
debug: CUSTOM FIND CONVO undefined undefined
debug: DEFAULT SLACK MSG RECEIVED RESPONDER
debug: RECEIVED MESSAGE
debug: CUSTOM FIND CONVO U4HLW3BPV undefined
debug: DEFAULT SLACK MSG RECEIVED RESPONDER
Code:
if (!process.env.token) {
console.log('Error: Specify token in environment');
process.exit(1);
}
var Botkit = require('./lib/Botkit.js');
var os = require('os');
var controller = Botkit.slackbot({
debug: true,
});
var bot = controller.spawn({
token: process.env.token
}).startRTM();
hmm.. from the output it seems that the token was read (no 'Error: Specify token in environment' , "debug: rtm.start { no_unreads: true,
simple_latest: true,
token: 'xoxb...' }" is logged ) . So it's not a problem with environment
.
Yes, its strange that it will run from the cli, but not in webstorm.