[NPM] Execute Code from a Remote GitHub Branch with npx

We will see how you can use npx to pull and execute code from a GitHub repository. If you need even more control, you can target a specific branch of your repository to execute.

 

Using npx to access a remote github repo's branch:

npx <username>/<repo_name>#<branch_name>

 

For node, we have to have "bin" prop in package.json to tell which file to run:

"bin": {
    "runthiscommand": "./index.js"
 },

 

And for index.js file, on the top, you need to have:

#!/usr/bin/env node

 

posted @ 2019-03-12 19:23  Zhentiw  阅读(509)  评论(0编辑  收藏  举报