This topic is not meant to have a definitive solution.
In similar vein to my blog about my own dev configuration management techniques, I’ve had some slight frustration with the documented & recommended method for installing the Forge CLI. It’s a side effect of how node version managers work with a default npm configuration that installs global packages into the specific node version. As a consequence, I end up with a lot of Forge CLIs installed, each of which wants to nag me to update it to the latest.
My solution
Setup
mkdir ~/npm-global
cd ~/npm-global
npm init --yes
npm install @forge/cli@latest
Then I modify the package.json
to “unpin” the dependency
{
"dependencies": {
"@forge/cli": "*"
}
}
Profile
For my zsh-based setup, I configure the path in .zshrc
:
NPM_GLOBAL="$HOME/npm-global"
if [[ -d "$NPM_GLOBAL/node_modules/.bin" ]]; then
export PATH="$NPM_GLOBAL/node_modules/.bin:$PATH"
fi
Make sure to source
the config or restart the shell.
Maintenance
Now, when I get those messages from Forge CLI, I run these commands:
cd ~/npm-global
npm outdated
npm update
To streamline, the outdated
option can be skipped but I prefer to know what I’m about to change.
Better ideas?
If it isn’t obvious, this is a bit more general than just for Forge CLI. I can do a “global” install of any npm package this way.
But I do wonder if any Node experts who know a better way?