Skip to content

Instantly share code, notes, and snippets.

@Tynael
Last active February 18, 2026 00:49
Show Gist options
  • Select an option

  • Save Tynael/0861d31ea17796c9a5b4a0162eb3c1e8 to your computer and use it in GitHub Desktop.

Select an option

Save Tynael/0861d31ea17796c9a5b4a0162eb3c1e8 to your computer and use it in GitHub Desktop.
How to use npx to run gist based scripts
#!/usr/bin/env node
console.log("I was executed from a gist inside the terminal with npx!");
{
"name": "run-js-with-npx-from-gist",
"version": "1.0.0",
"bin": "./index.js"
}
@romualdovillalobos

Copy link
Copy Markdown

Amazing!! thanks

@maan-singh

Copy link
Copy Markdown

nice

@Tynael

Tynael commented Jun 5, 2020

Copy link
Copy Markdown
Author

@dagolinuxoid, @xerosanyam, @lantosgyuri, @robert-rae, @MohammadMojtabaRoshani-TOMaaR, @romualdovillalobos, @maan-singh
Thank you for the kind words, folks! I really hope it helped you!

@fredsced

Copy link
Copy Markdown

Thanks for the explanation

@RyotaBannai

Copy link
Copy Markdown

Such an awesome feature I've never imagined the mere local command being capable of this! Thank you for this education!

@mdn-cloud

Copy link
Copy Markdown

It was really helpful for me as a new learner!!! thanks a lot!!

@jonasmateus

Copy link
Copy Markdown

This example was extremely helpful! Thanks a lot :)

@lukaskoeller

Copy link
Copy Markdown

Is there any possibility to have arguments in the scripts which values are provided through options in the npx command?
Something like: npx <url-to-gist> --source ./path/to/source --dest ./path/to/dest?

@Tynael

Tynael commented Sep 9, 2020

Copy link
Copy Markdown
Author

Thank you, @fredsced, @RyotaBannai, @mdn-cloud, @jonasmateus.

@lukaskoeller I don't know tbh, haven't tried that yet ^^

@Temi-t

Temi-t commented Dec 18, 2020

Copy link
Copy Markdown

Thanks. This was helpful

@sa2kasov

Copy link
Copy Markdown

I've read your article in russian from here

@jtello

jtello commented Apr 21, 2021

Copy link
Copy Markdown

Thanks!

@bennythejudge

Copy link
Copy Markdown

thanks!!

@fernandoadms

Copy link
Copy Markdown

Thanks for the article!!

@ydjaghloul

Copy link
Copy Markdown

very nice, thanks

@Tynael

Tynael commented Jun 7, 2021

Copy link
Copy Markdown
Author

Thanks, @Temi-t, @Sadvakasov, @jtello, @bennythejudge, @fesantossp, @ydjaghloul! πŸŽ‰

@ashiquem

Copy link
Copy Markdown

Super clear explanation and very helpful, thanks!

@Tynael

Tynael commented Jun 24, 2021

Copy link
Copy Markdown
Author

Thanks, @ashiquem!

I've also created a video on this subject if you prefer this format. You can check it out here:

https://www.youtube.com/watch?v=fSHWc8RTJug

@zjkuang

zjkuang commented Mar 3, 2022

Copy link
Copy Markdown

Amazing!!! I tried with my gist and it is working like a charm!

@codcarry

Copy link
Copy Markdown

Thanks sharing about npx ~ Here I have a problem ,the time when I run "npx https://gist.github.com/Tynael/0861d31ea17796c9a5b4a0162eb3c1e8" ,my terminal show below words "[..................] - rollbackFailedOptional: verb npm-session e08d5c3184bda02a".I want to konw what happened.
Looking forward to your recovery~

@Tynael

Tynael commented Nov 15, 2022

Copy link
Copy Markdown
Author

Hi @codcarry!
That is a npm specific issue that can have many different causes of malfunction.
I suggest having a look on Google and see what works for you: https://www.google.com/search?q=-+rollbackFailedOptional%3A+verb+npm-session&sourceid=chrome&ie=UTF-8

@codcarry

Copy link
Copy Markdown

Thanks very much,I'll try to resolve this.

Hi @codcarry! That is a npm specific issue that can have many different causes of malfunction. I suggest having a look on Google and see what it works for you: https://www.google.com/search?q=-+rollbackFailedOptional%3A+verb+npm-session&sourceid=chrome&ie=UTF-8

Thanks very much,I'll try to resolve this.

@kelvinpraises

Copy link
Copy Markdown

@Tynael Thanks for the article πŸ‘

@facuso162

Copy link
Copy Markdown

Very handful article, TY πŸ‘

@yenche123

Copy link
Copy Markdown

Awesome! Thank you!

@Tynael

Tynael commented Jan 15, 2025

Copy link
Copy Markdown
Author

@kelvinpraises, @facuso162, @yenche123, happy to help πŸ’œ

@lmihaylov2512

Copy link
Copy Markdown

Great explanation of the differences between npm and npx πŸ™

@wagnermor

wagnermor commented Jul 21, 2025

Copy link
Copy Markdown

Thanks

@pasaperez

Copy link
Copy Markdown

Interesting, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment