使用npm run dev时,脚本“node app.js”运行。但是当我尝试运行它时,我收到此错误代码:
C:\Users\rfasc\Dropbox\Hackathon\HackCuTwitter>npm run dev
> Tweeter@1.0.0 dev C:\Users\rfasc\Dropbox\Hackathon\HackCuTwitter
> node app.js
Error: Status Code: 401
at Request.<anonymous (C:\Users\rfasc\Dropbox\Hackathon\HackCuTwitter\node_modules\twitter\lib\twitte
r.js:274:28)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at Request.onRequestResponse (C:\Users\rfasc\Dropbox\Hackathon\HackCuTwitter\node_modules\request\request.js:
1074:10)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at HTTPParser.parserOnIncomingClient [as onIncoming]
(_http_client.js:473:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)
at TLSSocket.socketOnData (_http_client.js:362:20)
at emitOne (events.js:96:13)
当我在cmd中使用bash尝试运行sudo时,我也遇到了这个错误:
ryryfasch@LAPTOP-9TPB1OJ6:/mnt/c/Users/rfasc/Dropbox/Hackathon/HackCuTwitter$ sudo i
sudo: unable to resolve host LAPTOP-9TPB1OJ6
我尝试过查找许多修复程序但无法弄明白。感谢。
这是我的app.js文件:
var twitterpack = require('twitter');
var tokens = {
consumer_key: '----------SaaqAe9yVvr30CF',
consumer_secret: '---------------oK7Dfj3zoiZ2nUOTBWUjP4DqtGXIlzzbxbOY',
token_key: ' -----------------3N6RZJeOtJeH8ZhrursJUQlAqCycHqxbl',
token_secret: '---------------2QYwSSZStETF7Mr2mBikHYCTTqodV'
}
var Twitter = new twitterpack(tokens);
Twitter.stream('statuses/filter', {track: 'hey'}, function(stream) {
stream.on('data', function(stream){
console.log(tweet.text);
var meanReply = {status: "hey @" + tweet.user.screen_name}
Twitter.post('statuses/update', meanReply, function(error, tweetReply, response){
if(error) {console.log(error) /*&&db.collection('errors', error.text)*/};
console.log(tweetReply.text)}
);
});
stream.on('error', function(error) {
console.log(error);
});
});