I would like to run a TypeScript script from a launchd.

I'm successfully running the script directly using npx ts-node /path/to/script.ts

However I can't figure out how to code this into the plist file. I have:


But this exits with code 78. It would seem npx cannot be found (I see that in the LaunchControl app); but I can't figure out how to address npx correctly.

Update: Fixed the code 78 thanks to @nohillside and updated npx to /usr/local/bin/npx; but now logging the error env: node: No such file or directory


1 Answer 1


Most likely the path to npx is not in the default PATH. Run type npx in Terminal and then use the full path shown for the first string in your launchd plist.

As the PATH issue can proliferate, the actually better way might be to create a wrapper (shell) script which gets called by launchd, and export a adapted PATH in that script before calling npx.

  • Thank you; I didn't know about type; getting further - but now exits with 127 with the error env: node: No such file or directory logged Jan 1 at 17:50
  • @BenRobinson This basically is the same issue again. I‘ve added a second option to the answer.
    – nohillside
    Jan 1 at 18:24
  • 1
    Your absolutely correct that PATH was the issue, however I was able to fix it by adding <key>EnvironmentVariables</key><dict><key>PATH</key><string>/usr/local/bin:/bin</string></dict> to the plist - thanks Jan 6 at 15:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .