Skip to content

Better npm global install

By Brian Sunter

Posted in Programming, Javascript

A better way to manage global npm command line tools.

I've always disked running npm install -g create-react-appto have a command line tool. I also dislike npx create-react-app because it downloads the dependencies every time. I can't keep track of it or lock down the version easily. Instead I have a project in my dotfiles which I add to my path.

In my ~/.dotfiles directory I have a node folder with a package.json. Whenever I need a tool I install it to this project.

In my ~/.zshrc I add ~/.dotfiles/node/node_modules/.bin to my $PATH.

export PATH="$HOME/.dotfiles/node/node_modules/.bin:$PATH"

Now I can access these npm command line tools and keep them versioned.

Brian Sunter
Brian Sunter

I've spent all my life on top of a mountain, learning the way of the Ninja Dev.