anoff / remote-code

live-reload for ssh connected devices 🐪
MIT License
6 stars 3 forks source link

I got a "TypeError" #9

Open mjarkk opened 5 years ago

mjarkk commented 5 years ago

I cloud not get this tool to work..
Due to this error:

.-(~/Documents/test)
`--> remote-code root@some-host.com
🐪      starting remote-code
✈️       syncing files
📦      dependency installation started
💣      TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be one of type string, Buffer, or URL. Received type undefined
🐪      shutting down remote-code

My package .json:

{
  "name": "test",
  "version": "1.0.0",
  "scripts": {
    "start": "node index.js"
  },
  "main": "index.js",
  "license": "MIT",
  "dependencies": {}
}

The contents of index.js:

let count = 0
const run = () => {
        setTimeout(() => {
                count ++
                console.log(count)
                run()
        }, 200)
}
run()

Env information

The host (my laptop)

The client (my server)

anoff commented 5 years ago

Sorry again for not responding earlier; is this still a problem or did you get it to work? I will try to find out which component throws that error and tomorrow try your code

anoff commented 5 years ago

Since the error seems to be during the install routine which is just yarn by default could you maybe try:

  1. running yarn manually in the remote directory
  2. use remote-code --install "npm install" instead
mjarkk commented 5 years ago

That didn't work.
remote-code --install "npm install" gave the same error
yarn also didn't work

I now also have nodemon installed on my client and host.

When i ssh into my server there is folder named: remote-sync in /root with the host's files.

When i run yarn start or npm start on my server they both execute the scripts.

In my package.json i have a main defined.

Files in host's dir:

-rw-r--r-- 1 mark users index.js
drwxr-xr-x 3 mark users node_modules
-rw-r--r-- 1 mark users package-lock.json
-rw-r--r-- 1 mark users package.json
-rw-r--r-- 1 mark users yarn.lock

Using a random dependencies just to have something in the dependencies also didn't work.

anoff commented 5 years ago

Does running the install command (either yarn or npm install) on the machine itself work?

mjarkk commented 5 years ago

Jup they both work on the host and on the client

anoff commented 5 years ago

hey @mjarkk sorry for taking so long. I can confirm the same behavior with my setup. However instead of trying to fix the old version I am currently working on getting the latest master commit working. There were several changes in the dependencies that I would like to get published.

mjarkk commented 5 years ago

That's oke i found this project interesting and wanted to try it out.

anoff commented 5 years ago

Could you please try it with the npm i -g remote-code@next version?

For me the following command works remote-code -i ~/.ssh/id_rsa pi@robby5 -p 2221 -S ls -t "~/debug" using your example files

mjarkk commented 5 years ago

Just tried it and there seem to be a view errors.
Here are the problems.

Preview:
Note: That error is because i killed the app via a task manager. image

anoff commented 5 years ago

Ahh, are you not using a private key to authenticate your SSH connection? How do you log into the remote machine usually?

That might explain also you previous error

mjarkk commented 5 years ago

just do ssh root@machine.com and i'm in, I have multiple private keys stored in ~/.ssh/
In there i also have a config file with a list of all my keys

IdentityFile ~/.ssh/someEmail@gmail.com
IdentityFile ~/.ssh/id_rsa
...
anoff commented 5 years ago

well good thing I figured out where the type error is coming from. I always assumed that people use a keyfile, that's why it tried to read an unspecified path resulting in this error. The catch I introduced recently makes sure that there always is a keyfile used - but I am not really happy with that. But there is something in the dependencies I use that results in a weird state (same you had). I have to work on the error handling for this one.