22

After installing angular-seed project, i did the following steps:

Cloned the repository :

git clone https://github.com/angular/angular-seed.git

cd angular-seed

Then I ran npm install

at the end of the install i get:

angular-seed@0.0.0 prestart C:\Users\user\Documents\GitHub\comilion\angular-seed npm install

angular-seed@0.0.0 postinstall C:\Users\user\Documents\GitHub\myproject\angular-seed bower install

angular-seed@0.0.0 start C:\Users\user\Documents\GitHub\myproject\angular-seed http-server -a localhost -p 2324

'http-server' is not recognized as an internal or external command, operable program or batch file.

npm ERR! angular-seed@0.0.0 start: http-server -a localhost -p 2324 npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the angular-seed@0.0.0 start script. npm ERR! This is most likely a problem with the angular-seed package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR!
http-server -a localhost -p 2324 npm ERR! You can get their info via: npm ERR! npm owner ls angular-seed npm ERR! There is likely additional logging output above. npm ERR! System Windows_NT 6.1.7601 npm ERR! command "C:\Program Files\nodejs\\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "start" npm ERR! cwd C:\Users\user\Documents\GitHub\myproject\angular-seed npm ERR! node -v v0.10.22 npm ERR! npm -v 1.3.14 npm ERR! code ELIFECYCLE npm ERR! npm ERR! Additional logging details can be found in: npm ERR!
C:\Users\user\Documents\GitHub\myproject\angular-seed\npm-debug.log

please let me know if you have any suggestions how to solve this issue.

Liad Livnat
  • 7,435
  • 16
  • 60
  • 98

7 Answers7

79

@BenFortune found the answer it was

http-server needs to be installed globally with npm install -g http-server

Mörre
  • 5,699
  • 6
  • 38
  • 63
Liad Livnat
  • 7,435
  • 16
  • 60
  • 98
  • 2
    This solves the issue but it does not have to be installed globally. see: https://stackoverflow.com/a/31340713/5598783 – e-shfiyut Jun 14 '18 at 13:48
26

If the accepted solution did not work for you. Try the following. This solved the issue in my system.

Make sure the locations of both npm and http-server are added in environment variable 'PATH' (Both user variable and System variable).

If it is not present,

add C:\Users\username\AppData\Roaming\npm and C:\Users\username\AppData\Roaming\npm\node_modules\http-server to environment variable 'PATH'

Nithin Baby
  • 7,486
  • 4
  • 21
  • 25
8

If you are using Window 10. Then after run

npm install -g http-server

The http-server.cmd will available in C:\Users\your-user\AppData\Roaming\npm

Then check if `http-server` work in `cmd` or not.
  • If it works, you don't need to see the below part.
  • If it not work. You need to check Environment Variable
  • If you add variable to Path (inside admin). You need to run cmd as Administrator.
  • If you add variable to Path (inside System variable). You don't need to run cmd as Administrator.
  • Add C:\Users\your-user\AppData\Roaming\npm -> OK -> OK -> Re-open the cmd.
  • The http-server will work
Linh
  • 57,942
  • 23
  • 262
  • 279
4
npm install -g http-server

Use this command to install http-server module into your project. You can verify this in package.json

harshavmb
  • 3,404
  • 3
  • 21
  • 55
joedavis
  • 86
  • 4
3

You can fix the issues by doing the following steps,

  1. Install http-server globally by npm install -g http-server
  2. Added 'PATH' in environment variable for system variable. Path will be like this C:\Users\username\AppData\Roaming\npm
  • Hi, I am getting the error http-server : The term 'http-server' is not recognized as the name of a cmdlet when I run http-server. It was working fine till yesterday and all of sudden its trowing this error. I verified the Path for both npm and http-server in Environmental variables and added them, but still issue not fixed. I even tried uninstalling and reinstalling the http-server. Any idea what might be the issue. – Vin Aug 21 '19 at 21:59
  • I found the solution for my issue and just sharing it here so if someone needs it. In the Path as mentioned above when I specify `%AppData%\Roaming\npm\node_modules`, the error is displayed. The reason is because the %AppData% was already set as `C:\Users\username\AppData\Roaming` in my profile and so the folder path I gave is invalid. When I removed that Roaming from the path then it started working. – Vin Aug 22 '19 at 13:41
0

For me all that had to be done after the basic install

npm install http-server -g

Is to run as administrator from the project directory this command:

http-server dist/project-name
Orit
  • 314
  • 2
  • 6
0

1-remove http-server by command

npm uninstall http-server -g 

2- install again

npm install http-server -g 
hassan khademi
  • 1,156
  • 12
  • 14