NodeJS - 如何解决“无法找到模块'ar-drone'”错误

时间:2015-04-08 03:55:29

标签: node.js ar.drone

我在命令提示符下安装了以下软件包:

npm install -g ar-drone

然后点击Node.js

var arDrone = require('ar-drone');

它让我无法找到模块'ar-drone'

我想当我用-g安装它时会全局安装吗?

我做错了什么?

2 个答案:

答案 0 :(得分:1)

是的,我必须将所有代码从index.js传输到repl.js。我的repl.js看起来像这样并且可以工作。

let arDrone = exports;

exports.Client           = require('./lib/Client');
exports.UdpControl       = require('./lib/control/UdpControl');
exports.PngStream        = require('./lib/video/PngStream');
exports.UdpNavdataStream = require('./lib/navdata/UdpNavdataStream');

exports.createClient = function(options) {
  let client = new arDrone.Client(options);
  client.resume();
  return client;
};

exports.createUdpControl = function(options) {
  return new arDrone.UdpControl(options);
};

exports.createPngStream = function(options) {
  let stream = new arDrone.PngStream(options);
  stream.resume();
  return stream;
};

exports.createUdpNavdataStream = function(options) {
  let stream = new arDrone.UdpNavdataStream(options);
  stream.resume();
  return stream;
};
let client  = arDrone.createClient();
client.createRepl();

答案 1 :(得分:0)

如果您使用ubuntu,请检查模块是否已在/usr/local/lib/node_modules下载。这是node_modules的全球位置。

您也可以尝试在本地目录中安装。