Npm install eslint often fails, and takes time. how to only do it once

I want to run eslint as part of my checks

so one of my dependencies is npm install -g eslint

but this sometimes fails due to network error.

however in reality it would be easy to have this in the cache and not always install it.
I’ve found a mechanism to install only once, but this would require an exceedingly long command line, or preferrably a means to define a shell function.

is there a way to define a shell function? Or is there a better way to only install a node module once?

Actually my working plan for this is to do: [ "type -p eslint" == "eslint not found" ] && npm install -g eslint

1 Like