我是Node.js的新手,我正在尝试在本地计算机上运行Flickr API: https://github.com/ciaranj/flickrnode 我用npm install flickr安装了flickr模块。
最简单的电话是:
var FlickrAPI= require('flickr').FlickrAPI;
var sys= require('sys');
var flickr= new FlickrAPI(your_api_key_here);
// Search for photos with a tag of 'badgers'
flickr.photos.search({tags:'badgers'}, function(error, results) {
sys.puts(sys.inspect(results));
});
我已经将'sys'更改为'util',因为节点提示我并添加了我的api密钥,所以我打电话:
var FlickrAPI= require('flickr').FlickrAPI;
var sys= require('util');
var flickr= new FlickrAPI('...');
// Search for photos with a tag of 'badgers'
flickr.photos.search({tags:'badgers'}, function(error, results) {
sys.puts(sys.inspect(results));
});
运行节点myfile.js,我得到:
var flickr= new FlickrAPI('a513719086ba8c3a28d2c7726939b58e');
^
TypeError: undefined is not a function
at Object.<anonymous> (/home/charm/ciaranj-flickrnode-8a9d85f/lib/simple.js:3:13)
at Module._compile (module.js:446:26)
at Object..js (module.js:464:10)
at Module.load (module.js:353:31)
at Function._load (module.js:311:12)
at Array.0 (module.js:484:10)
at EventEmitter._tickCallback (node.js:190:38)
有谁知道我是如何克服这个问题的?
谢谢!
答案 0 :(得分:0)
npm install flickr
安装https://github.com/sujal/node-flickr,而不是您正在寻找的那个。 How to install a node.js module without using npm?解释了如何手动安装节点包