Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

FWIW, you can usually just drop the `-g` and it'll install into `node_modules/.bin` instead, so it stays local to your project. You can run it straight out of there (by typing the path) or do `npm run <pkg>` which I think temporarily modifies $PATH to make it work.


The `npx` command (which comes bundled with any nodejs install) is the way to do that these days.


`npx` doesn't update package.json/package.lock though, right? So you might get a different version of the package once awhile. If it's an executable you depend on for your project, it makes sense to version it IMO.


You can do a (local) install using `npm install` and then execute the binary using `npx`. npx will also try to fetch the binary over the network if you don't have it installed, which is questionable behaviour in my opinion, but you can just cancel this if it starts doing it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: