Troubleshooting HubSpot CMS CLI setup with NPM

Hey everyone, I’m having a hard time getting the HubSpot CMS CLI to work with NPM. I thought it would be easy but I’m stuck. Here’s what I’ve tried:

  1. I installed NPM and it seems to be working fine.
  2. I ran npm install -g @hubspot/cms-cli in the /usr/local/bin/ folder.
  3. When I try hs init, I get a ‘command not found’ error.
  4. npm list shows up empty.
  5. In my project folder, it says HubSpot is installed but there’s nothing under it.
  6. I tried installing in the project folder too, but same problem.

I’m pretty sure I’m missing something obvious. Can anyone help me figure out what I’m doing wrong? Thanks!

I’ve been there, John. The HubSpot CMS CLI can be tricky to set up. From what you’ve described, it sounds like the global installation didn’t quite go as planned. Here’s what worked for me:

Instead of installing in /usr/local/bin/, try running the install command from your home directory. Also, make sure you’re using sudo if you’re on Mac or Linux:

sudo npm install -g @hubspot/cms-cli

After that, you might need to refresh your terminal or open a new one. If it still doesn’t work, check your PATH variable to ensure npm’s global bin directory is included.

As a last resort, you could try uninstalling and reinstalling Node.js and npm completely. Sometimes a fresh start does the trick.

Hope this helps! Let us know if you get it working.

I had a similar experience with the HubSpot CMS CLI not being recognized even though npm appeared to install it correctly. In my case, the issue stemmed from the CLI not being added to the system’s PATH automatically. I resolved it by first checking the global installation directory using npm commands and then ensuring that this directory was included in my PATH. Once the PATH was updated and my terminal restarted, the command worked without issue. It is also worth considering reinstalling the CLI with appropriate permissions if problems persist.

yo john, i had similar probs. try runnin the install command from ur home directory instead. also, make sure ur using sudo if ur on mac/linux. like this:

sudo npm install -g @hubspot/cms-cli

if that dont work, check ur PATH. sometimes npm global bin aint there. good luck mate!