fix npm global install needs sudo ================================= Each time I go to set up npm I am frustrated by the errors saying that I don't have permission to , and it's frustrating. And I forget what I need to do to... Date: April 11, 2024 Each time I go to set up npm I am frustrated by the errors saying that I don't have permission to `npm i -g `, and it's frustrating. And I forget what I need to do to tell npm to install packages in a directory I own, and my shell to look there so that I can use the executables. ``` bash mkdir ~/.npm-global export NPM_CONFIG_PREFIX=~/.npm-global export PATH=$PATH:~/.npm-global/bin ``` For the fix to remain persistent you need to put these two lines in your shell profile like `~/.bashrc` or `~/.zshrc`. ``` bash export NPM_CONFIG_PREFIX=~/.npm-global export PATH=$PATH:~/.npm-global/bin ```