Unrecognized PORT command

浪子不回头ぞ 提交于 2020-05-11 06:58:07

问题


In my localhost, running below command

PORT=4080 node server.js

But, it was throwing an unexpected error.

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

Do I need to install any module or did I miss any syntax to run it properly?


回答1:


Apart from cross-env, Below command can serve the purpose.

SET PORT=4080 && node server.js 

PS: Set environment variable for nodeJs, run command in project folder.




回答2:


  • Install this additional package cross-env in your node environment. The above command you mentioned is Unix (Ubuntu, Mac, etc…). In the windows environment, you need a different syntax and cross-env does your job.
  • You can also create an .env file with

PORT=3006

and save it in your project directory.




回答3:


SET PORT=8090 && nodemon server.js that worked for me




回答4:


Here's a moronic way I found to recreate this problem:

  1. Create a npm based app on one system
  2. check it out on another system
  3. FAIL to run npm install
  4. run npm start

Receive error described in question.



来源:https://stackoverflow.com/questions/47806623/unrecognized-port-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!