Quantcast
Viewing all articles
Browse latest Browse all 6112

npx command fails with ENOENT when running via SSH

I want to run the following command in my CI/CD to execute some commands on my Ubuntu 23.10 server after deployment:

ssh user@123.456.789.10 "cd path/to/directus && PATH=/path/to/.nvm/versions/node/v20.10.0/bin && npx directus schema snapshot --yes ./snapshot.yaml"

Unfortunately this command fails always with:

npm ERR! code ENOENTnpm ERR! syscall spawn shnpm ERR! path /path/to/directusnpm ERR! errno -2npm ERR! enoent spawn sh ENOENTnpm ERR! enoent This is related to npm not being able to find a file.npm ERR! enoentnpm ERR! A complete log of this run can be found in: /path/to/.npm/\_logs/2024-03-03T00_02_07_460Z-debug-0.log

In the log file I have this:

34 timing command:exec Completed in 144ms35 verbose stack Error: spawn sh ENOENT35 verbose stack     at ChildProcess._handle.onexit (node:internal/child_process:286:19)35 verbose stack     at onErrorNT (node:internal/child_process:484:16)35 verbose stack     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)36 verbose pkgid directus-backend@1.0.037 verbose cwd /path/to/directus38 verbose Linux 6.5.0-17-generic39 verbose node v20.10.040 verbose npm  v10.2.541 error code ENOENT42 error syscall spawn sh43 error path /path/to/directus44 error errno -245 error enoent spawn sh ENOENT46 error enoent This is related to npm not being able to find a file.46 error enoent47 verbose exit -248 timing npm Completed in 676ms49 verbose code -250 error A complete log of this run can be found in: /path/to/.npm/_logs/2024-03-03T12_24_23_416Z-debug-0.log

I don't know which file it couldn't find because the snapshot.yaml is at the respective location. I get also the same error if I run npx directus database migrate:latest.

When I log into my server with ssh user@123.456.789.10 and then run the commands manually the commands run without issues.

I also tried to enforce a bash shell with bash -c in the ssh command but that doesn't help either.


Viewing all articles
Browse latest Browse all 6112

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>