需要npm包后出错

我试图在树莓派上运行一个电子应用程序。 当我在我的代码中使用var TJBot = require('tjbot')来导入节点包时,会出现以下错误:

 ## There is an issue with `node-fibers` ## `/Users/apple/app/node_modules/asyncawait/node_modules/fibers/bin/darwin-x64-53/fibers.node` is missing. Try running this to fix the issue: /Users/apple/app/node_modules/electron/dist/Electron/ app/Contents/Frameworks/Electron Helper.app/Contents/MacOS/Electron Helper /Users/apple/app/node_modules/ asyncawait/node_modules/fibers/build Uncaught Error: Missing binary. See message above. at Object.<anonymous> (/Users/apple/app/node_modules/asyncawait/node_modules/fibers/fibers.js:20:8) at Object.<anonymous> (/Users/apple/app/node_modules/asyncawait/node_modules/fibers/fibers.js:26:3) at Module._compile (module.js:571:32) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) 

如果我删除这条线或运行它没有使用电子,一切工作正常,所以我不知道如果这个节点库有问题或它是由电子

Inside /Users/apple/app/node_modules/asyncawait/node_modules/fibers/bin/我可以看到

 darwin-ia32-46 darwin-x64-48 linux-ia32-48 repl win32-x64-46 darwin-ia32-48 darwin-x64-51 linux-x64-46 win32-ia32-46 win32-x64-48 darwin-x64-46 linux-ia32-46 linux-x64-48 win32-ia32-48 

为什么我需要darwin-x64-53 ,它来自哪里?

纤维是build立到本地二进制代码,它不是纯粹的JavaScript。 Rasperry Pi运行在ARM上,不包含在预先创build的二进制文件中。 预构build的二进制文件支持OSX(达尔文),linux和windows的32位和64位体系结构。

这意味着您需要为您的系统手动构buildFibers,而不是通过NPM进行安装。 纤维自述文件有明确的说明。 我已经把它们包括在这里,以方便访问。 请按照这些说明尝试运行在Raspberry Pi / ARM上。

从源代码安装

  • git clone git://github.com/laverdet/node-fibers.git
  • cd node-fibers
  • npm install

注意:节点光纤使用node-gyp进行构build。 要手动调用构build过程,可以使用node-gyp rebuild 。 这将把编译的扩展放在build/Release/fibers.node 。 但是,当你require('fibers') ,它会希望模块处于,例如bin/linux-x64-v8-3.11/fibers.node 。 您可以在每次构build时手动将模块放置在此处,也可以使用包含的构build脚本。 npm installnode build -f将为您做这个。 如果你打算在节点光纤上进行攻击,首先进行node-gyp configure ,然后为了后续的重build,你可以做node-gyp build ,这比完整的npm installnode-gyp rebuild