live-server package is used to create a local server to help you develop applications.
Sometimes, the error
live-server command not found error may appear after you’ve installed it as follows:
$ live-server bash: live-server: command not found
This error happens because your computer can’t find the globally installed
First, make sure that you are installing the package using the
npm install --global live-server # or npm install -g live-server
Once installed, you need to check for the global installation path of your npm packages using the
npm bin -g command.
Here’s an example output of the command:
$ npm bin -g # 👇 example output on Windows C:\Users\nathan\AppData\Roaming\npm\ # 👇 example output on Mac or Linux /usr/local/bin
The global install path you get with the
npm bin -g command needs to be available from the PATH environment variable of your computer.
To update the PATH on a Windows computer, you need to follow the steps below:
- Open the Start menu and type env in the search bar.
- A menu named Edit the system environment variables should show up. Click on the menu
- Click on Environment Variables… button
- Open the Path variable and see if the
npm bin -gpath is added as an entry
You should see something similar to this:
Save the changes by clicking the OK button, then open a new command line or Git Bash window.
You should be able to run
live-server successfully now.
On Mac or Linux computers, you need to add the bin location to the
.bashrc file depending on the terminal you use on the computer.
The RC files should be available in the user’s root directory of the user when you open the terminal.
You can move to your root directory by running the
cd ~ command.
EXPORT PATH variable in the RC file as follows:
/usr/local/bin above with your
npm bin -g output. Also, make sure there is a colon
: before the
$PATH variable as shown above.
That should help you to run the
live-server package on Mac and Linux computers.
If you’re installing Node using NVM, then you need to make sure the following entries are defined in your RC files
export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
NVM_DIR variable must point to an existing nvm folder.
For Windows, you need to check the Path variables and make sure there are
%NVM_SYMLINK% variables added:
If you don’t see the variables as shown above, try to add them manually and open a new command line window.
When that doesn’t work, then try reinstalling NVM for Windows.
And that’s how you fix the
live-server command not found error. 👍