You may not have your npm binaries in PATH
.
Make sure that your npm binaries are in path by running echo $PATH
. You should see, somewhere in the printed output, something like:
/home/bob/.npm-packages/bin:/usr/lobal/bin:/other/paths/that/contain/bins
/home/bob/.npm-packages/bin
is the directory where my npm binaries are installed whenever I run npm -g install whatever
.
If you don’t see something like that, read Fixing npm permissions which will walk you through making sure that your environment is set up correctly. Option 2 explicitly talks about fixing PATH
.
Another handy thing that I usually do is add all this to my .bashrc
or .bashprofile
which is in your home directory:
- On macOS
/Users/username/
- On *nix:
/home/username/
.bashrc
NPM_PACKAGES="${HOME}/.npm-packages" PATH="$NPM_PACKAGES/bin:$PATH"
However, since it looks like you are using zshell, you’ll have to use whatever convention they follow for rc files.
You can either fix that or, you can install http-server at a package level for your project and then start it through an npm command.
Run npm install --save-dev http-server
and put in your package.json:
{ "scripts": { "start": "http-server ." } }
and then run
npm start