每當我執行我的計劃,我收到以下TypeError
:Node.js的類型錯誤:對象函數對象(){[本地代碼]}有沒有方法「分配」
/home/Node-Project/node_modules/sentiment/lib/index.js:31
afinn = Object.assign(afinn, inject);
^
TypeError: Object function Object() { [native code] } has no method 'assign'
at module.exports (/home/Node-Project/node_modules/sentiment/lib/index.js:31:24)
at EventEmitter.<anonymous> (/home/Node-Project/twit4.js:17:9)
at EventEmitter.emit (events.js:95:17)
at EventEmitter.processTweet (/home/Node-Project/node_modules/ntwitter/lib/twitter.js:242:14)
at EventEmitter.emit (events.js:95:17)
at EventEmitter.receive (/home/Node-Project/node_modules/ntwitter/lib/parser.js:44:12)
at IncomingMessage.<anonymous> (/home/Node-Project/node_modules/ntwitter/lib/twitter.js:258:16)
at IncomingMessage.emit (events.js:95:17)
at IncomingMessage.<anonymous> (_stream_readable.js:765:14)
at IncomingMessage.emit (events.js:92:17)
我搜索,但我無法瞭解這個錯誤。
我必須安裝特殊模塊嗎?
我必須更新Node或npm嗎?
我的程序中是否有錯誤?
這裏是我的程序:
var twitter = require('ntwitter');
var credentials = require('./credentials3.js');
var sentiment = require ('sentiment');
var twit = new twitter({
consumer_key: credentials.consumer_key,
consumer_secret: credentials.consumer_secret,
access_token_key: credentials.access_token_key,
access_token_secret: credentials.access_token_secret
});
twit.stream('statuses/filter',{ 'locations':'loc'},
function(stream) {
stream.on('data', function(tweet) {
var twitterSentiment, geoColor;
sentiment(tweet.text, function (err, result) {
twitterSentiment = result;
if (result == 0) {
geoColor = '#B5B5B5';
} else if (result < 0) {
geoColor = '#FC0828';
} else {
geoColor = '#00DE1E';
} console.log(result);
});
});
});
是否有人可以提供一些線索?
* 「我一定要更新節點」 *最有可能的。你使用哪個版本?看看http://node.green/看你的版本是否支持Object.assign。 –