Npm “scripts”: “start” run express and open url

前端 未结 3 1453
感动是毒
感动是毒 2021-02-01 15:51

I have this start params in package.json

\"scripts\": {
    \"start\": \"node bin/www\"
  },

It is running my express app when I a

相关标签:
3条回答
  • 2021-02-01 16:06

    As far as I know it's like writing a bash command:

    // Windows
    "start":"start http://localhost:8081 & node bin/www"
    
    // Mac
    "start":"open http://localhost:8081 && node bin/www"
    
    // Linux
    "start":"xdg-open http://localhost:8081 && node bin/www"
    
    0 讨论(0)
  • 2021-02-01 16:08

    For cross-platform support use open-cli.

    Install it:

    npm install --save-dev open-cli
    

    Add it to your scripts:

    "start": "open-cli http://localhost:8081 && node bin/www"
    
    0 讨论(0)
  • 2021-02-01 16:16

    You just need to use start in the right order!

    "start": "npm run dev & start http://localhost:8000",
    

    Bad

    "start": "start http://localhost:8000 & npm run dev",
    

    Good

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