2

Note: I have tried almost all similar posts related to this issue and found nothing was helpful to me. Hence posting this.

Issue: I'm trying to install http-server package in my Windows 7 machine using npm install http-server -g, Installation was fine, however when I try to execute it using http-server command in the command line I'm getting an error saying, 'http-server' is not recognized as an internal or external command, operable program or batch file. I have also tried the same steps for gulp and the result was the same.

I have tried setting the Node Path as, set NODE_PATH=%AppData%\npm\node_modules; but no luck.

Can someone shed some light here?

Thanks, Dave

David R
  • 14,711
  • 7
  • 54
  • 72
  • 1
    Have you installed the package using an admin console (Run as Administrator)? – Oscar Sep 07 '16 at 12:39
  • 1
    It may be helpful http://stackoverflow.com/questions/9587665/nodejs-cannot-find-installed-module-on-windows – abdulbarik Sep 07 '16 at 12:40
  • @Oscar Do you mean opening the CMD with "Run as Administrator" option? – David R Sep 07 '16 at 14:37
  • @DavidR Yes. At least in Linux, you need to make "sudo" to install globally – Oscar Sep 07 '16 at 14:39
  • @Oscar I don't have admin privileges right now, will approach my IT support and will get back to you. Thanks for the tip! – David R Sep 07 '16 at 14:40
  • @Oscar, Just realized that, I have the required admin access, and when I tried I had no luck as I'm having the same messages again. :( – David R Sep 07 '16 at 14:44
  • 1
    Is there a `http-server` executable in `C:/Program Files (x86)/nodejs/node_modules`? That's where it [should be installed](https://docs.npmjs.com/files/folders) if you used `-g`. – Aurora0001 Sep 07 '16 at 14:57
  • No.. But I do have a `http-server.cmd` file created now after following @Oscar 's suggestion. It executes only when I navigate my command prompt to `users\dave\AppData\Roaming\npm`. I guess I need to use the `SET PATH` command now. – David R Sep 07 '16 at 15:01
  • Yes! After setting the path it executes fine. – David R Sep 07 '16 at 15:03
  • @Oscar Can you please post you suggestion as answer, so that I can mark it answered for you? – David R Sep 07 '16 at 15:04
  • @Aurora0001 Can you please post you suggestion as answer, so that I can put a upvote for you? – David R Sep 07 '16 at 15:04
  • 1
    @DavidR I don't think my comment is enough to count as an answer, but thanks a lot for the thought - I'm just glad you managed to figure it out. – Aurora0001 Sep 07 '16 at 15:06
  • 1
    @Aurora0001 Really appreciate your help!. :-) – David R Sep 07 '16 at 15:10
  • @DavidR Done, thanks! – Oscar Sep 07 '16 at 15:26

1 Answers1

2

Global packages needs to be installed using and administration console (CMD / Run as Administrator)

Oscar
  • 13,594
  • 8
  • 47
  • 75