Unrecognized PORT command

前端 未结 7 1534
没有蜡笔的小新
没有蜡笔的小新 2021-02-14 04:43

In my localhost, running below command

PORT=4080 node server.js

But, it was throwing an unexpected error.

\'PORT\' is no

相关标签:
7条回答
  • 2021-02-14 05:07

    You can try this way also

     "scripts": {
        "build": "concurrently \"cd client && npm build\" \"cd server && npm build\"",
        "install": "(cd client && npm) && (cd server && npm)",
        "start": "concurrently \"cd client && SET PORT=3000 && npm start\" \"cd server && SET PORT=3001 && npm start\"",
        "start:prod": "cd server && npm start:prod"
      }
    
    0 讨论(0)
  • 2021-02-14 05:14

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

    0 讨论(0)
  • 2021-02-14 05:20

    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.

    0 讨论(0)
  • 2021-02-14 05:21

    automatically run this port :3000,I tried windows working react

    "devDependencies": {
        "react-scripts": "0.8.4"
      },
      "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "test": "react-scripts test --env=jsdom",
        "eject": "react-scripts eject"
      }
    
    0 讨论(0)
  • 2021-02-14 05:22

    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.

    0 讨论(0)
  • 2021-02-14 05:26
    • 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.

    0 讨论(0)
提交回复
热议问题