0

I need to run HOST=localhost npm run start:debug to run my server. This command works fine on my mac. In windows cmd and powershell throw these errors respectively.

HOST=localhost : The term 'HOST=localhost' 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

 cmd:-
'HOST' is not recognized as an internal or external command,
operable program or batch file.

Package.json:-

"start:debug": "export NODE_PATH=`pwd`/src; node --harmony -r babel-register 
 --inspect bin/webpack-dev-server"
  • Where is the PS code where you have defined the host and other details? Please edit the question and share the minimal,complete,verifiable code . – Ranadip Dutta Apr 29 '18 at 08:36
  • C:\Windows\System32\drivers\etc Host file contains # localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost – Natansh Prasad Apr 29 '18 at 09:30

2 Answers2

0

Environment variables work differently in PowerShell. What you want is more along the lines of:

$env:HOST = 'localhost'; npm run start:debug

But note that the HOST env variable will be in effect for other commands from that point on, as well. There are known workarounds for that, if that's a problem for you.

Rytmis
  • 31,467
  • 8
  • 60
  • 69
  • Unfortunately looks like, the script uses directives that aren't supported by Windows and only would work on Unix using bash and zsh. Thanks for the answer. Your answer helped me to understand how different these shells are. – Natansh Prasad Apr 29 '18 at 09:49
  • 1
    I was able to use **git bash** to avoid 'HOST' is not recognized as an internal or external command problem on windows. – Natansh Prasad Apr 29 '18 at 10:20
0

This is how I solved the problem. The commands I was using were made for Unix so I installed bash shell command line for windows. Here is a guide:- https://www.windowscentral.com/how-install-bash-shell-command-line-windows-10

After that, you can find your drive in 'mnt' directory. To go to c drive type:-

cd mnt/c

Navigate to your project directory. You will need to install node, yarn and run npm install again.

https://nodesource.com/blog/installing-node-js-tutorial-ubuntu/

after running npm install. Run

yarn

Do a restart if you are having any problems with npm. This fixed my problem hope it helps.