'http-server' is not recognized as an internal or external command

后端 未结 6 633
鱼传尺愫
鱼传尺愫 2021-02-05 11:12

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

Cloned the repository :

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

相关标签:
6条回答
  • 2021-02-05 11:45

    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'

    0 讨论(0)
  • 2021-02-05 11:58

    @BenFortune found the answer it was

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

    0 讨论(0)
  • 2021-02-05 12:02
    npm install -g http-server
    

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

    0 讨论(0)
  • 2021-02-05 12:02

    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
    
    0 讨论(0)
  • 2021-02-05 12:07

    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
    0 讨论(0)
  • 2021-02-05 12:08

    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
    0 讨论(0)
提交回复
热议问题