【问题标题】:Why is node giving me this error?为什么节点给我这个错误?
【发布时间】:2017-04-22 22:14:04
【问题描述】:

我一直在尝试制作我的第一个 twitter 机器人,但是当我运行 npm run dev 时出现此错误:

> Tweeter@1.0.0 dev /mnt/c/Users/rfasc/Dropbox/Hackathon/HackCuTwitter
> node app.js

npm ERR! weird error 1
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! not ok code 0 

我对使用 nodejs 和 npm 命令连接我的代码有点陌生。这是我的 package.json 和 app.js 文件:

package.json:

{
  "name": "Tweeter",
  "version": "1.0.0",
  "description": "package.json tester",
  "main": "app.js",
  "dependencies": {
    "twitter": "^1.7.0",
    "twitter-stream-api": "^0.5.1"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "node app.js"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/kennychiwa/HackCuTwitter.git"
  },
  "author": "",
  "license": "BSD-2-Clause",
  "bugs": {
     "url": "https://github.com/kennychiwa/HackCuTwitter/issues"
  },
  "homepage": "https://github.com/kennychiwa/HackCuTwitter#readme"
}

和 app.js:

var twitterpack = require('twitter');

var tokens {
  consumer_key: '-------9WJSaaqAe9yVvr30CF',
  consumer_secret: '-------------------fj3zoiZ2nUOTBWUjP4DqtGXIlzzbxbOY',
  token_key: '  ----------zNHmdL43N6RZJeOtJeH8ZhrursJUQlAqCycHqxbl',
  tokenk_secre: '----EcxAjUq1hLka2QYwSSZStETF7Mr2mBikHYCTTqodV'
}
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);
  });
});

请帮忙,谢谢。

【问题讨论】:

  • 你的操作系统(我看到的可能是 os x)和节点版本是什么?
  • Windows 10 及版本:v0.10.25 @h0x91B
  • Nodejs 真的太老了 :),当前版本是 6.10.2,试试升级一下吧

标签: javascript json node.js npm


【解决方案1】:

你能试试这个命令吗

sudo ln -s /usr/bin/nodejs /usr/bin/node

【讨论】:

  • 我做到了并带来了这个:ln: failed to create symbolic link ‘/usr/bin/node’: File exists
  • sudo apt-get install nodejs-legacy 你可以试试这个并告诉我
猜你喜欢
  • 2011-09-07
  • 1970-01-01
  • 2022-08-12
  • 1970-01-01
  • 2012-04-25
  • 2015-06-25
  • 2013-11-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多