termux / termux-app

Termux - a terminal emulator application for Android OS extendible by variety of packages.
https://f-droid.org/en/packages/com.termux
Other
31.28k stars 3.32k forks source link

[Bug]: Run npm start in new session return 127 #3873

Closed storytellerF closed 1 month ago

storytellerF commented 2 months ago

Problem description

Open new session window and run command npm start to run react web project, it will faile. And log is

> web@0.1.0 start > react-scripts start

sh: 1: react-scripts: not found

[Process completed (code 127) - press Enter]

If I manually create session and run commond npm start, there is no error.

Steps to reproduce the behavior.

  1. create or clone a react project
  2. run command
    am startservice -n com.termux/.app.TermuxService \
        -a com.termux.service_execute \
        -d /data/data/com.termux/files/usr/bin/npm \
        --ez com.termux.app.failsafe_session false \
        --es com.termux.execute.cwd "/data/data/com.termux/files/home/projects/your-project-name/web" \
        --esa com.termux.execute.arguments start

What is the expected behavior?

react project run without error

System information

sylirre commented 2 months ago

Where do you have react-scripts utility installed?

If it is under custom PATH, then not found error would be expected. The way you are using to run npm would cause the default PATH to be set. This is not a bug. Just you give no chance for Termux session to go through full login initialization.

storytellerF commented 2 months ago

@sylirre I see. Is there a way to execute command after login in a new session?

storytellerF commented 1 month ago

I use tmux resolve this problem.