homebridge / node-pty-prebuilt-multiarch

A parallel fork of node-pty providing ia32, amd64, arm, and aarch64 prebuilt packages for macOS, Windows and Linux (glibc and musl libc).
https://www.npmjs.com/package/@homebridge/node-pty-prebuilt-multiarch
Other
31 stars 15 forks source link

"Cannot find module" error on Ubuntu #8

Closed bartbutenaers closed 3 years ago

bartbutenaers commented 5 years ago

Environment details

Issue description

Dear, Thanks for sharing this VERY useful node!!! I have used it on my Windows 10 portable, and there it was running very smooth, but not on ubuntu.

  1. In the package.json file of my custom node, I have added following dependencies:

    "dependencies": {
       "xterm": "4.2.0-vscode1",
       "xterm-addon-fit": "0.3.0",
       "node-pty-prebuilt-multiarch": "0.9.0"
    },
  2. I use this dependency in the Javascript code of my (NodeJs) node:

    var pty = require('node-pty-prebuilt-multiarch');
  3. When I install my node (directly from my Github repository), I can see that a build is initiated:

pi@PortableAsus:~/.node-red$ sudo npm install bartbutenaers/node-red-contrib-xterm [sudo] password for pi:

node-pty@0.9.0 install /home/pi/.node-red/node_modules/node-pty node scripts/install.js

make: Entering directory '/home/pi/.node-red/node_modules/node-pty/build' CXX(target) Release/obj.target/pty/src/unix/pty.o SOLINK_MODULE(target) Release/obj.target/pty.node COPY Release/pty.node make: Leaving directory '/home/pi/.node-red/node_modules/node-pty/build'

node-pty@0.9.0 postinstall /home/pi/.node-red/node_modules/node-pty node scripts/post-install.js

node-red-project@0.0.1 /home/pi/.node-red ├── node-pty@0.9.0 extraneous ├── node-red-contrib-interval-length@0.0.4 extraneous (git://github.com/bartbutenaers/node-red-contrib-interval-length.git#d5ec6c2eb484ca8b24b11a23eaaeb422aaa34ff2) ├── node-red-contrib-json-db@0.6.2 extraneous ├── node-red-contrib-multipart-stream-decoder@0.0.4 extraneous ├── node-red-contrib-ui-contextmenu@1.0.4 extraneous (git://github.com/bartbutenaers/node-red-contrib-ui-contextmenu.git#47e779b1cb7fceb2fdcb8ef4cfaf208e12d114f4) ├── node-red-contrib-ui-heatmap@2.1.2 extraneous ├── node-red-contrib-ui-svg@1.2.2 extraneous ├── node-red-contrib-web-push@0.0.1 extraneous ├── node-red-contrib-web-worldmap@2.1.3 extraneous ├── node-red-contrib-xterm@0.0.1 extraneous (git://github.com/bartbutenaers/node-red-contrib-xterm.git#e7089aba9e81aac1f8929fd294e45c210a097a94) ├── web-push@3.4.1 extraneous ├── UNMET PEER DEPENDENCY xterm@^4.0.0 └── xterm-addon-fit@0.3.0

npm WARN enoent ENOENT: no such file or directory, open '/home/pi/.node-red/node_modules/node-red-contrib-drawsvg/package.json' npm WARN xterm-addon-fit@0.3.0 requires a peer of xterm@^4.0.0 but none was installed.

  1. The content of that folder looks like this:

pi@PortableAsus:~/.node-red/node_modules/node-pty/build$ ls -ltr total 24 -rw-r--r-- 1 pi pi 4066 Nov 18 08:08 config.gypi -rw-r--r-- 1 pi pi 3303 Nov 18 08:08 pty.target.mk -rw-r--r-- 1 pi pi 111 Nov 18 08:08 binding.Makefile -rw-r--r-- 1 pi pi 12629 Nov 18 08:08 Makefile drwxr-xr-x 1 pi pi 4096 Nov 18 08:09 Release

  1. And that "Release" folder contains this file:

pi@PortableAsus:~/.node-red/node_modules/node-pty/build/Release$ ls -ltr total 36 -rwxr-xr-x 1 pi pi 35216 Nov 18 08:09 pty.node

  1. Then I start the application (Node-RED from IBM that loads my node as a plugin), but I get this:

pi@PortableAsus:~/.node-red$ sudo node --inspect=0.0.0.0:5858 /usr/local/lib/node_modules/node-red/red.js Debugger listening on ws://0.0.0.0:5858/c5cb2c6a-b0d5-4967-8e38-8e9f782074c4 For help see https://nodejs.org/en/docs/inspector 18 Nov 08:10:40 - [info]

Welcome to Node-RED

18 Nov 08:10:40 - [info] Node-RED version: v1.0.1 18 Nov 08:10:40 - [info] Node.js version: v8.10.0 18 Nov 08:10:40 - [info] Linux 4.4.0-18362-Microsoft x64 LE 18 Nov 08:10:41 - [info] Loading palette nodes 18 Nov 08:11:03 - [info] Worldmap version 2.1.3 innerError { Error: Cannot find module '../build/Debug/pty.node' at Function.Module._resolveFilename (module.js:547:15) at Function.Module._load (module.js:474:25) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at Object. (/home/pi/.node-red/node_modules/node-pty-prebuilt-multiarch/lib/unixTerminal.js:30:15) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) code: 'MODULE_NOT_FOUND' } 18 Nov 08:11:05 - [info] Dashboard version 2.17.0 started at /ui 18 Nov 08:11:05 - [warn] ------------------------------------------------------ 18 Nov 08:11:05 - [warn] [node-red-contrib-xterm/xterm_shell] Error: Cannot find module '../build/Release/pty.node' 18 Nov 08:11:05 - [warn] ------------------------------------------------------ 18 Nov 08:11:05 - [info] Settings file : /home/pi/.node-red/settings.js

It is not clear to my why it is looking for a 'Debug' directory, while the build only created a 'Release' directory. And the error message (that Node-RED catches) seems to be referring to the 'Release' folder.

Do you have any idea what I could be doing wrong?

Thanks in advance!! Bart Butenaers

oznu commented 5 years ago

Can you try a newer version of Node.js? node-pty requires v10 or later.

What's your cpu architecture?

uname -a
bartbutenaers commented 5 years ago

pi@PortableAsus:~/.node-red$ uname -a Linux PortableAsus 4.4.0-18362-Microsoft #476-Microsoft Fri Nov 01 16:53:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux

Might this be perhaps some issue: I run Ubuntu in Windows 10 (like you can see here).

I have upgraded NodeJs to version v10.17.0 (recommended version for Node-RED), but then the problem still occurs:

18 Nov 13:53:50 - [info] Node-RED version: v1.0.1 18 Nov 13:53:50 - [info] Node.js version: v10.17.0 18 Nov 13:53:50 - [info] Linux 4.4.0-18362-Microsoft x64 LE 18 Nov 13:53:50 - [info] Loading palette nodes innerError { Error: Cannot find module '../build/Debug/pty.node' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18) at Object. (/home/pi/.node-red/node_modules/node-pty-prebuilt-multiarch/lib/unixTerminal.js:30:15) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) code: 'MODULE_NOT_FOUND' } 18 Nov 13:54:14 - [info] Worldmap version 2.1.3 18 Nov 13:54:16 - [info] Dashboard version 2.17.0 started at /ui 18 Nov 13:54:16 - [warn] ------------------------------------------------------ 18 Nov 13:54:16 - [warn] [node-red-contrib-xterm/xterm_shell] Error: Cannot find module '../build/Release/pty.node' 18 Nov 13:54:16 - [warn] ------------------------------------------------------ 18 Nov 13:54:16 - [info] Settings file : /home/pi/.node-red/settings.js

Swivelgames commented 4 years ago

@bartbutenaers After you updated your node version, did you delete your node_modules directory and reinstall your modules?

This is highly recommended after any node version change, as certain modules (including this one) can be sensitive to version changes.

blueedgetechno commented 2 years ago

It is throwing the same error. Here I've using it for an atom package called atomforces . It was using node-pty initially but was rather chosen to be replaced with node-pty-prebuilt-multiarch due to performance issues on windows. But now after switching it works on windows but throws an error on ubuntu.

Here is the error:

Atom: 1.58.0 x64 Electron: 9.4.4 Node: 10.19.0 OS: Ubuntu 20.04.3 (Linux blue 5.11.0-41-generic #45~20.04.1-Ubuntu SMP Wed Nov 10 10:20:10 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux) Thrown From: atomforces package 0.4.1

Stack Trace Failed to activate the atomforces package ``` At Cannot find module '../build/Release/pty.node' Require stack: - /home/blue/Documents/atomforces/node_modules/node-pty-prebuilt-multiarch/lib/prebuild-loader.js - /home/blue/Documents/atomforces/node_modules/node-pty-prebuilt-multiarch/lib/unixTerminal.js - /home/blue/Documents/atomforces/node_modules/node-pty-prebuilt-multiarch/lib/index.js - /home/blue/Documents/atomforces/lib/business/compiler.js - /home/blue/Documents/atomforces/lib/business/file-watcher.js - /home/blue/Documents/atomforces/lib/atomforces.js - /usr/share/atom/resources/app.asar/static/index.html Error: Cannot find module '../build/Release/pty.node' Require stack: - /home/blue/Documents/atomforces/node_modules/node-pty-prebuilt-multiarch/lib/prebuild-loader.js - /home/blue/Documents/atomforces/node_modules/node-pty-prebuilt-multiarch/lib/unixTerminal.js - /home/blue/Documents/atomforces/node_modules/node-pty-prebuilt-multiarch/lib/index.js - /home/blue/Documents/atomforces/lib/business/compiler.js - /home/blue/Documents/atomforces/lib/business/file-watcher.js - /home/blue/Documents/atomforces/lib/atomforces.js - /usr/share/atom/resources/app.asar/static/index.html at Module._resolveFilename (internal/modules/cjs/loader.js:797:17) at o._resolveFilename (electron/js2c/renderer_init.js:43:689) at Function.get_Module._resolveFilename (/usr/share/atom/resources/app/static/:11:157920) at Module.require (/app.asar/static/index.js:61:43) at require (/usr/share/atom/resources/app/static/:11:149207) at Object. (/home/blue/Documents/atomforces/node_modules/node-pty-prebuilt-multiarch/lib/prebuild-loader.js:6:11) at Object. (/home/blue/Documents/atomforces/node_modules/node-pty-prebuilt-multiarch/lib/prebuild-loader.js:20:3) at Module.get_Module._compile (/usr/share/atom/resources/app/static/:11:149891) at Object.value [as .js] (/usr/share/atom/resources/app/static/:11:153485) at Module.load (internal/modules/cjs/loader.js:815:32) at Module._load (internal/modules/cjs/loader.js:727:14) at Function.Module._load (electron/js2c/asar.js:769:28) at Module.require (/app.asar/static/index.js:72:46) at require (/usr/share/atom/resources/app/static/:11:149207) at Object. (/home/blue/Documents/atomforces/node_modules/node-pty-prebuilt-multiarch/lib/unixTerminal.js:25:25) at Object. (/home/blue/Documents/atomforces/node_modules/node-pty-prebuilt-multiarch/lib/unixTerminal.js:266:3) at Module.get_Module._compile (/usr/share/atom/resources/app/static/:11:149891) at Object.value [as .js] (/usr/share/atom/resources/app/static/:11:153485) at Module.load (internal/modules/cjs/loader.js:815:32) at Module._load (internal/modules/cjs/loader.js:727:14) at Function.Module._load (electron/js2c/asar.js:769:28) at Module.require (/app.asar/static/index.js:72:46) at require (/usr/share/atom/resources/app/static/:11:149207) at Object. (/home/blue/Documents/atomforces/node_modules/node-pty-prebuilt-multiarch/lib/index.js:14:20) at Object. (/home/blue/Documents/atomforces/node_modules/node-pty-prebuilt-multiarch/lib/index.js:52:3) at Module.get_Module._compile (/usr/share/atom/resources/app/static/:11:149891) at Object.value [as .js] (/usr/share/atom/resources/app/static/:11:153485) at Module.load (internal/modules/cjs/loader.js:815:32) at Module._load (internal/modules/cjs/loader.js:727:14) at Function.Module._load (electron/js2c/asar.js:769:28) ```