Http-server: when I run http-server on mac, I receive ```zsh: command not found: http-server```

Created on 2 Feb 2019  路  5Comments  路  Source: http-party/http-server

I've just moved to macOS from win10. And I've never worked in a mac before. I've met many problems. This is one of them. I can't figure out what's wrong, because the error msg is too,,,,, simple. Can anyone can help me on this? Any help is appreciated. The env is followed. thanks.

  • macOS Mojave 10.14.1
    env

Most helpful comment

The problem is that you've installed http-server with sudo. sudo is a very powerful command, similar to administrator privileges on Windows. It would be useful to learn more about sudo and all it can do!

http-server usually should not be installed with sudo, so in this case you should do use npm install -g http-server, and then it should work! Alternatively, you can also use npx http-server to run it on the fly (without needing to install explicitly first).

I'm going to close this issue for now, but feel free to comment again if you have any trouble, questions or comments.

All 5 comments

The problem is that you've installed http-server with sudo. sudo is a very powerful command, similar to administrator privileges on Windows. It would be useful to learn more about sudo and all it can do!

http-server usually should not be installed with sudo, so in this case you should do use npm install -g http-server, and then it should work! Alternatively, you can also use npx http-server to run it on the fly (without needing to install explicitly first).

I'm going to close this issue for now, but feel free to comment again if you have any trouble, questions or comments.

@thornjad Sorry for forgetting this issue. Because I鈥檝e been on my new year holiday. I鈥檝e almost forgetten i鈥檓 a programmer. Thank you very much.

Hey no problem! Hope you had a great holiday!

I'm still having this issue without Sudo. I have been using a Python alternative to this program and unfortunately alot of tuts etc use this module. Any assistance ?

Wait I fixed this issue using this Stack Overflow and the subsequent links on it took me to a Resolving an EACCESS permissions error which had some insightful tips that helped me complete a test module to a new global installation configuration for my NPM packages and also assisted with the $PATH insertion of http-server from that ~/.npm-global directory the documentation guided me through. for future references feel free to check it out EACESS PERMISSIONS DOCS

Was this page helpful?
0 / 5 - 0 ratings