-1

How can I change my port into 4900 by using npm, because I can't change my port by using ng s --port 4900.

Message showing:

PS G:\PROJECTS\PetroHSE> ng s --port 4900
ng : The term 'ng' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1

  • ng s --port 4900
  • ~~
    • CategoryInfo : ObjectNotFound: (ng:String) [], CommandNotFoundException
    • FullyQualifiedErrorId : CommandNotFoundException and if I use npm s --port 4900 showing

PS G:\PROJECTS\PetroHSE> npm s --port 4900 NAME | DESCRIPTION | AUTHOR | DATE | VERSION | KEYWORDS sfs4900 | Transliteration… | =petuomin | 2016-11-02 | 0.0.1 | SFS-4900 sfs4900 standard romanization russian finnish transliteration @alifd/theme-4900 | Powered By… | =mark-ck… | 2019-01-15 | 0.1.1 | PS G:\PROJECTS\PetroHSE> npm start How can I change port by using npm?

2 Answers2

0

Probably you do not have angualar cli installed globally. Many people do, but you certainly do not have to (I definitely prefer not to)

You can use 2 ways to accomplish what you want:

  1. use npx: npx ng serve --port=4900 or npx ng s --port=4900 (s NOT -s)
  2. edit the file package.json In here you will find a part with scripts. You'll see that by default start script has ng serve in it. Edit this to ng serve --port=4900, save and exit. Then just run npm start. This option is more useful if you always want to start the server locally on this port.
Chai
  • 1,796
  • 2
  • 18
  • 31
0

it appears that Angular CLI is not installed globally.

Try running npm install -g @angular/cli

this command will install Angular CLI globally.

Meher Hendi
  • 66
  • 1
  • 4