Installing packages locally rather than globally (npx)

#1

I used to install packages globally (npm i -g truffle anyone?) but have now moved to installing locally as I often need different versions between projects.

I recently came across npx (I am new to the JavaScript world, sorry if this is really old news).
npx is a npm package runner which is installed along with npm.

This allows me to run local packages easily and even run packages I haven’t installed.

I also did a check of what I had installed globally.
npm list -g --depth 0
I then uninstalled everything I didn’t absolutely need globally, which was pretty much everything.

Would appreciate thoughts on local vs global.

2 Likes
#2

:heart: being able to run packages without installing

npx cowsay OpenZeppelin

1 Like
#3

Installing globally may cause issues when different projects require different versions, configurations, etc., and makes the whole project environment harder to reproduce (because it assumes global state). The only benefit is not having to type npx, so local installation is a big win for me.

2 Likes