假设我创建了一个 my-npx-hello-world 存储库
它有以下文件
my-npx-hello-world/
foo.sh
index.sh
package.json
package.json 有
"bin": "./index.sh"
index.sh 调用 ./foo.sh 即
#!/bin/sh
echo "running foo"
./foo.sh
现在,当我尝试运行它时
# npx my-npx-hello-world
running foo
line 4: ./foo.sh: No such file or directory
那是因为它在我的 CWD 中而不是在 my-npx-hello-world 存储库中寻找 foo.sh。
我需要做什么才能让 index.sh 在同一个 repo 中执行 foo.sh 脚本。