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

installation problem #91

Closed mercoglianoisidoro closed 4 years ago

mercoglianoisidoro commented 5 years ago

Hello, I am having problem during espruino installation. After the command: sudo npm i -g espruino

Here the result:

npm WARN deprecated tar.gz@1.0.7: ⚠️  WARNING ⚠️ tar.gz module has been deprecated and your application is vulnerable. Please use tar module instead: https://npmjs.com/tar
/usr/bin/espruino -> /usr/lib/node_modules/espruino/bin/espruino-cli.js

> @serialport/bindings@2.0.7 install /usr/lib/node_modules/espruino/node_modules/@serialport/bindings
> prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild

prebuild-install WARN install EACCES: permission denied, access '/home/mercogliano/.npm'
gyp WARN EACCES user "root" does not have permission to access the dev dir "/home/mercogliano/.node-gyp/10.6.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/tmp/.node-gyp"
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/espruino/node_modules/@serialport/bindings/build'
gyp ERR! System Linux 4.13.0-46-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/lib/node_modules/espruino/node_modules/@serialport/bindings
gyp ERR! node -v v10.6.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 

> usb@1.5.0 install /usr/lib/node_modules/espruino/node_modules/usb
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp WARN Pre-built binaries not installable for usb@1.5.0 and node@10.6.0 (node-v64 ABI, glibc) (falling back to source compile with node-gyp) 
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/usr/lib/node_modules/espruino/node_modules/usb/src/binding' 
gyp WARN EACCES user "root" does not have permission to access the dev dir "/home/mercogliano/.node-gyp/10.6.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/tmp/.node-gyp"
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/espruino/node_modules/usb/build'
gyp ERR! System Linux 4.13.0-46-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/lib/node_modules/espruino/node_modules/usb/src/binding/usb_bindings.node" "--module_name=usb_bindings" "--module_path=/usr/lib/node_modules/espruino/node_modules/usb/src/binding" "--napi_version=3" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v64"
gyp ERR! cwd /usr/lib/node_modules/espruino/node_modules/usb
gyp ERR! node -v v10.6.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/lib/node_modules/espruino/node_modules/usb/src/binding/usb_bindings.node --module_name=usb_bindings --module_path=/usr/lib/node_modules/espruino/node_modules/usb/src/binding --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/espruino/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:961:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
node-pre-gyp ERR! System Linux 4.13.0-46-generic
node-pre-gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/espruino/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/lib/node_modules/espruino/node_modules/usb
node-pre-gyp ERR! node -v v10.6.0
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok 
Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/lib/node_modules/espruino/node_modules/usb/src/binding/usb_bindings.node --module_name=usb_bindings --module_path=/usr/lib/node_modules/espruino/node_modules/usb/src/binding --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)

> bluetooth-hci-socket@0.5.1 install /usr/lib/node_modules/espruino/node_modules/bluetooth-hci-socket
> node-gyp rebuild

gyp WARN EACCES user "root" does not have permission to access the dev dir "/home/mercogliano/.node-gyp/10.6.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/tmp/.node-gyp"
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/espruino/node_modules/bluetooth-hci-socket/build'
gyp ERR! System Linux 4.13.0-46-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/lib/node_modules/espruino/node_modules/bluetooth-hci-socket
gyp ERR! node -v v10.6.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @serialport/bindings@2.0.7 (node_modules/espruino/node_modules/@serialport/bindings):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @serialport/bindings@2.0.7 install: `prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: usb@1.5.0 (node_modules/espruino/node_modules/usb):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: usb@1.5.0 install: `node-pre-gyp install --fallback-to-build`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: bluetooth-hci-socket@0.5.1 (node_modules/espruino/node_modules/bluetooth-hci-socket):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: bluetooth-hci-socket@0.5.1 install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

I checked a lot, it's not a problem of right access. The espruino command result installed, but it can't find any devices.

Node version is: v10.6.0

Thank, Isidoro.

gfwilliams commented 5 years ago

What platform are you on? And do you need Bluetooth, or serial?

Can you just try installing node-serialport and see if that fails? If it does I'd report the issue there.

We've had a bunch of trouble with node 10 - it seems the Bluetooth and serial port libraries are broken (i thought they were fixed my now though) - so the safest option is just to move back to node 8

m-onz commented 5 years ago

I'm running ubuntu 18.. I managed to get the install to work I like this...

sudo npm install espruino -g --build-from-source --unsafe-perm

I get a bluetooth related error/ warning:

binding.target.mk:101: recipe for target 'Release/obj.target/binding/src/BluetoothHciSocket.o' failed
make: *** [Release/obj.target/binding/src/BluetoothHciSocket.o] Error 1
make: Leaving directory '/usr/lib/node_modules/espruino/node_modules/bluetooth-hci-socket/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)

But things seem to work if I then always make sure to pass the no bluetooth flag...

sudo espruino -p /dev/ttyACM0 ./test.js --no-ble
Espruino Command-line Tool 0.1.23
-----------------------------------

Connecting to '/dev/ttyACM0'
(node:16035) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(.
Connected
--] 
--]  ____                 _ 
--] |  __|___ ___ ___ _ _|_|___ ___ 
--] |  __|_ -| . |  _| | | |   | . |
--] |____|___|  _|_| |___|_|_|_|___|
--]          |_| espruino.com
--]  2v01 (c) 2018 G.Williams
--] 
--] >44

Running --list without --no-ble gives me an empty list... with the --no-ble flag I see connected boards. This may be useful to others who use linux and do not have Bluetooth working or dont have a Bluetooth drivers that supports BLE.

gfwilliams commented 5 years ago

Thanks for the update! What happens without --no-ble? Could you try and post a stack trace?

If EspruinoTools can be made to trap the error and carry on without BLE that'd obviously be better than it just not working.

Although obviously bluetooth-hci-socket working with Node 10 would be preferable!

m-onz commented 5 years ago

I get no errors without the ble flag but also it doesnt work... using -v reveals that the issue it is related to bluetooth-hci-socket not being installing.

espruino -p /dev/ttyACM0 ./fade.js -v
0.1.23
Espruino Command-line Tool 0.1.23
-----------------------------------

Acorn library not found - you'll need it for compiled code
Found /usr/lib/node_modules/espruino/espruino.js
Found /usr/lib/node_modules/espruino/core/codeWriter.js
Found /usr/lib/node_modules/espruino/core/config.js
Found /usr/lib/node_modules/espruino/core/env.js
Found /usr/lib/node_modules/espruino/core/flasher.js
Found /usr/lib/node_modules/espruino/core/modules.js
Found /usr/lib/node_modules/espruino/core/notifications.js
Found /usr/lib/node_modules/espruino/core/serial.js
Found /usr/lib/node_modules/espruino/core/serial_chrome_serial.js
No chrome.serial - Chrome Serial disabled
Found /usr/lib/node_modules/espruino/core/serial_chrome_socket.js
No chrome.sockets - Chrome Socket disabled
Found /usr/lib/node_modules/espruino/core/serial_frame.js
Found /usr/lib/node_modules/espruino/core/serial_noble.js
Found /usr/lib/node_modules/espruino/core/serial_node_serial.js
Found /usr/lib/node_modules/espruino/core/serial_node_socket.js
Found /usr/lib/node_modules/espruino/core/serial_web_audio.js
Found /usr/lib/node_modules/espruino/core/serial_web_bluetooth.js
Found /usr/lib/node_modules/espruino/core/serial_websocket_local.js
Found /usr/lib/node_modules/espruino/core/serial_websocket_relay.js
Found /usr/lib/node_modules/espruino/core/serial_winnus.js
Not on Windows, Winnus not needed
Found /usr/lib/node_modules/espruino/core/terminal.js
Found /usr/lib/node_modules/espruino/core/utils.js
Found /usr/lib/node_modules/espruino/plugins/assembler.js
Found /usr/lib/node_modules/espruino/plugins/boardJSON.js
Found /usr/lib/node_modules/espruino/plugins/compiler.js
Found /usr/lib/node_modules/espruino/plugins/getGitHub.js
Found /usr/lib/node_modules/espruino/plugins/localModules.js
Found /usr/lib/node_modules/espruino/plugins/minify.js
Found /usr/lib/node_modules/espruino/plugins/saveOnSend.js
Found /usr/lib/node_modules/espruino/plugins/setTime.js
Found /usr/lib/node_modules/espruino/plugins/unicode.js
Found /usr/lib/node_modules/espruino/plugins/versionChecker.js
Initialising CodeWriter
Initialising Config
Initialising Env
Initialising Flasher
Initialising Modules
Initialising Notifications
Initialising Serial
  - Initialising Serial Noble Bluetooth LE
  - Initialising Serial Node Serial
  - Initialising Serial Node Socket
  - Initialising Serial Web Bluetooth
Initialising Utils
Initialising Status
Initialising Assembler
Initialising BoardJSON
Initialising Compiler
Initialising GetGitHub
Initialising LocalModules
Initialising Minify
Initialising SaveOnSend
Initialising SetTime
Initialising Unicode
Initialising VersionChecker
Connecting to '/dev/ttyACM0'
Noble: module couldn't be loaded, no node.js Bluetooth Low Energy
 { Error: Cannot find module 'bluetooth-hci-socket'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
    at Function.Module._load (internal/modules/cjs/loader.js:508:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/usr/lib/node_modules/espruino/node_modules/noble/lib/hci-socket/hci.js:6:26)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3) code: 'MODULE_NOT_FOUND' }
Noble: getPorts - not initialised
No navigator.bluetooth - Web Bluetooth not enabled
m-onz commented 5 years ago

Incidentally I did install this too

apt-get install libudev-dev

in response too an error during installation I saw...

Getting "fatal error: libudev.h: No such file or directory #include <libudev.h>" when compiling the package

Which may have helped during the npm install phase.

I have an issue running the watch flag -w eg.. espruino -p /dev/ttyACM0 -w ./test.js --no-ble. I think the expected behavior is that I should be able to type things directly into the console as If I was using chrome-app left hand console after the code has uploaded (correct me if I'm wrong). It seems to freeze and then direct the characters to stdout so that when I exit those characters appear in the shell.

To work around this I use screen in one terminal and avoid using the -w flag uploading code in a different terminal and everything works fine.

screen /dev/ttyACMO 9600
gfwilliams commented 5 years ago

Try updating from npm now - I think I at least fixed it so that if Noble fails to initialise then it keeps going on serial.

Honestly not sure what to suggest about -w. I'm on Linux here with Node 8 and that command works great for me

m-onz commented 5 years ago

I am trying node 8 and I'm testing things out but dealing with some NPM hanging issues now : )

There are some packages on NPM that are much simpler but they are 5 years old now and I don't know if they work with all the latest boards. The use case I have on linux is just uploading and seeing console output from the command line. I reckon a smaller package for that will be useful as not everyone needs all the functionality that the chrome app and EspruinoTools provides.

I may have a go working on a much smaller cli tool for these purposes.

PS. All my boards now work with the chrome app now so I'm happy!

Sorry for the long reply and great work as always!

gfwilliams commented 5 years ago

There are some packages on NPM that are much simpler

They don't work reliably - try uploading:

if (false) console.log("No")
else console.log("Yes");

I think pretty much all will fail, and I can point to loads of other cases.

Please don't make your own because it'll just add to the pile of out of date broken tools out there that confuse people.

EspruinoTools is actually pretty lightweight, and is designed to work with only the stuff you need (serial, TCPIP or Bluetooth). The issue you hit was just a bug - if you didn't have noble installed it'd have been fine - it was having a broken install of noble that caused the issue.

seancaulfield commented 5 years ago

So currently there's no support for BLE on Node.js 10 or 11? I'm trying to get a CLI working with a Puck.js and have been dealing with compile errors trying to install it.

gfwilliams commented 5 years ago

So currently there's no support for BLE on Node.js 10 or 11?

Which OS are you on?

noble is the main way to get Bluetooth LE on Node.js, and Node 10 changed something which meant that it broke. I keep thinking 'it'll be fixed soon' and it isn't (it hasn't been updated for a year) - I'll ask one of the maintainers what the situation is.

It looks like you may be able to use this version of noble though: https://www.npmjs.com/package/@abandonware/noble

pankleks commented 5 years ago

I have similar problem:

image

installing by: npm install espruino -g --build-from-source --unsafe-perm

OS -> Windows 10, Node -> 10.14.1

pankleks commented 5 years ago

just an update, my installation problem was solved by installing before:

npm install windows-build-tools -g

then

npm install espruino -g

gfwilliams commented 5 years ago

Thanks! I'll add that as a dependency on winnus, which should hopefully fix this?

gfwilliams commented 5 years ago

Just to add though - even if winnus fails, the tools should still be able to work with serial and with Bluetooth LE radios in HCI mode using noble

gfwilliams commented 4 years ago

Dependency added in https://github.com/espruino/winnus/commit/b33e503b2f13294c6be00c6ac1c7c0ea8913dd88 - closing