← Back
bash node npm tools

npx the things

I've recently learned that npx can be used, not only for avoid global packager installations, but also to run packages inside your current project:

npx ng generate component my-component

With npx, it uses the "ng" installed locally in your project, regardless of what you have installed globally. No more node_moules/.bin/ approach 👏

In fact, npx is quite a complex beast. Some (potentially dangerous) uses include running gists:

npx https://gist.github.com/elijahmanor/7f9762a4c2296839ad33e33513e88043

Running different node versions:

npx -p node@8.2.1 -- node index.js

Testing incoming package versions:

npx create-react-app@next playground

Execute code from a github repo in a specific branch:

npx danigb/destroy-your-computer#interactive