简体   繁体   English

如何为32位系统准备64位上的node.js模块?

[英]How to prepare node.js modules on 64bit for 32bit system?

I'm developing a node.js application on a 64bit Ubuntu machine that I intend to run on a Raspberry Pi running Rasbpian. 我正在64位Ubuntu计算机上开发一个node.js应用程序,该计算机打算在运行Rasbpian的Raspberry Pi上运行。 The Pi is not usually connected to the internet, so I manually copy the project folder to its SD card. Pi通常不连接到Internet,因此我将项目文件夹手动复制到其SD卡。 I can't run the application there since one of the required modules, epoll , apparently only works with 64 bit: 我无法在那里运行该应用程序,因为必需的模块之一epoll显然仅适用于64位:

Error: /home/pi/bla/node_modules/epoll/build/Release/epoll.node: wrong ELF class: ELFCLASS64 错误:/home/pi/bla/node_modules/epoll/build/Release/epoll.node:错误的ELF类:ELFCLASS64

at Object.Module._extensions..node (module.js:602:18) 在Object.Module._extensions..node(module.js:602:18)

at Module.load (module.js:507:32) at tryModuleLoad (module.js:470:12) 在module.load(module.js:507:32)在tryModuleLoad(module.js:470:12)

at Function.Module._load (module.js:462:3) 在Function.Module._load(module.js:462:3)

at Module.require (module.js:517:17) 在Module.require(module.js:517:17)

at require (internal/module.js:11:18) 在要求时(internal / module.js:11:18)

at bindings (/home/pi/bla/node_modules/bindings/bindings.js:76:44) 在绑定(/home/pi/bla/node_modules/bindings/bindings.js:76:44)

at Object. 在对象。 (/home/pi/bla/node_modules/epoll/epoll.js:1:99) (/home/pi/bla/node_modules/epoll/epoll.js:1:99)

at Module._compile (module.js:573:30) 在Module._compile(module.js:573:30)

at Object.Module._extensions..js (module.js:584:10) 在Object.Module._extensions..js(module.js:584:10)

This can be fixed by running npm uninstall epoll and then npm install epoll , but only when the Pi is connected to the internet. 可以通过运行npm uninstall epoll然后npm install epoll ,但npm install epoll是将Pi连接到互联网。 Of course I could just not copy this specific module, but is there a way to avoid this error otherwise? 当然,我不能复制此特定模块,但是有办法避免这种错误吗?

If you have no internet connection on install, then the only way is to prepare both 32bit and 64bit node_modules beforehand. 如果安装时没有Internet连接,则唯一的方法是事先准备32位和64位node_modules。 On first launch, just check your CPU and make node_modules symlink to node_modules_64 or node_modules_32 . 首次启动时,只需检查您的CPU并将node_modules符号链接到node_modules_64node_modules_32

The problem isn't anything to do with copying, it's because your trying to run packages that have been compiled using a 64-bit Node version under a 32-bit version. 问题与复制无关,这是因为您试图运行在32位版本下使用64位Node版本编译的程序包。

Compile your packages using the same bitness of Node on your Ubuntu system (you can install 32-bit Node on a 64-bit OS) and then copy them over. 使用Ubuntu系统上相同位的Node编译软件包(您可以在64位OS上安装32位Node), 然后将其复制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM