espruino / EspruinoTools

JavaScript library of tools for Espruino - used for the Web IDE, CLI, etc.
Apache License 2.0
150 stars 89 forks source link

Unable to install due to error in unmaintained dependency #174

Closed mordv closed 7 months ago

mordv commented 8 months ago

Related: #168

npm install -g espruino
...
npm ERR! command failed
npm ERR! command sh -c node scripts/download-prebuilt.js
npm ERR! /bin/sh: node-pre-gyp: command not found

The error goes from wrtc dependency from abandoned(https://github.com/node-webrtc/node-webrtc/issues/759) repo The wrtc dep is from peerjs-on-node which is unmaintained no-name fork of peerjs.

This was first attempt to play with espruino, so I don't know when and why p2p is used, but at first glance it seems as a minor feature which prevents the tool to be installed at all.

gfwilliams commented 8 months ago

It would appear to install just fine on my computers here, both windows and linux (on node 17/18) - but you're saying this is an issue specific to Mac OS in arm64?

What happens if you clone the repo and try and install with node-webrtc removed or as an optional dependency?

My concern is that for the Espruino CLI to be useful it needs to be able to access actual hardware - doing that requires either noble, node-serial or the webrtc, and I have a feeling that (maybe node-serial excluded) they all needed node-pre-gyp. noble is basically abandoned and so I'm pretty sure that won't have been updated.

So even if we can get it to install it may end up being kind of useless.

mordv commented 8 months ago

It's Mac OS, but on intel, so the problem not arm-specific.

What happens if you clone the repo and try and install with

A ton of errors from nobel, a couple of vulnerabilities from "noble-winrt" (2 moderate, 1 high)

a feeling that (maybe node-serial excluded) they all needed node-pre-gyp

Serialport seems to use node-pre-gyp, but the install goes ok.

With this setup the install is clean*:

  "dependencies": {
    "acorn": "^8.8.2",
    "es6-shim": "^0.35.8",
    "utf8": "^3.0.0",
    "ws": "^8.13.0"
  },
  "optionalDependencies": {
    "serialport": "^10.5.0",
    "websocket": "^1.0.34"
  },

*(except for the message from es5-ext recommending me to read some BBC news to know the truthâ„¢ https://github.com/medikoo/es5-ext/issues/116)

If you need p2p on node, peerjs seems to support it in beta https://github.com/peers/peerjs/pull/928. For BLE, there is https://github.com/chrvadala/node-ble which seems to be maintained

Also, I was surprised to see es6-shim dep (why would a user want to install this?) and no bundler at all. Have you considered using rollup.js?

Not giving any advices (except for rollup.js), I wrote that as a user who wants just-to-install-and-play, not seeing any errors, vulnerabilities and propaganda in my terminal.

gfwilliams commented 7 months ago

I've just moved peerjs-on-node to an optional dependency, so hopefully that'll solve your issue.

If you need p2p on node, peerjs seems to support it in beta

But that's beta? And peerjs-on-node seems to work fine and is reliable, apart from the install issue (but you appear to be the only one hitting that)

and no bundler at all

Why do I need rollup? It's just a node.js module?

I can't 100% remember but I think es6-shim is there because originally EspruinoTools was designed to run in the browser (and mainly it still does) - I think it provides some global that a part of the tools was expecting, and allows it to run in Node.js without me having to redo a bunch of stuff. Maybe that could be changed at some point now, I can't remember.

I wrote that as a user who wants just-to-install-and-play, not seeing any errors

Yes, this is a shame - but I have to maintain a whole bunch of different projects (for free), and honestly I could spend all my time just chasing these messages - swapping libraries, updating and so on - and I'd never actually end up fixing real issues or creating anything new.

EspruinoTools especially is just created as a helper for Node.js devs - the vast majority of users will be using https://www.espruino.com/ide/

If someone else wants to contribute a PR that improves the situation without breaking everything else then I'm all for it, but I just don't have time myself.

At the end of the day, if you want something that's 100% sandboxed that you trust, it's best to use the Web IDE at https://www.espruino.com/ide/

cjnqt commented 5 months ago

Just want to let you know that moving peer-js to optionalDependencies did not solve the issue, installation is currently broken on Mac OS (both on Intel and arch64) due to peerjs-on-node using wrtc, both of which are abandoned.

UPDATE:

  1. npm install github:espruino/EspruinoTools does work, but npm install espruino does not work, so I guess it is the npm registry that is lagging.

  2. Running npx espruino will fail because it will try to load node_modules/espruino/libs/webrtc-connection.js. Delete that file, and npx espruino works without webrtc

gfwilliams commented 5 months ago

Ok, I've just pushed a new version to NPM which might fix this for Mac

Running the CLI should now work even if Peer.js isn't installed as well

cjnqt commented 5 months ago

Perfect, works great