Wednesday, 15 March 2017

npm start to start both http-server and NodeJS app

I used a boilerplate for my project, and I am trying to achieve this:

  1. Start http-server on port 8000
  2. Start my NodeJS backend app

Inside my package.json I have something like this:

"scripts": {
    "prestart": "npm install",
    "start": "http-server -a localhost -p 8000 -c-1 ./app"
}

This starts a HTTP server on port 8000 with "root" being ./app. Now I've just started looking into implementing NodeJS into this as well, so I want to node ./app/Server/app.js when I do npm start, if that makes sense. I did try something like this:

"scripts": {
    "prestart": "npm install",
    "start": "http-server -a localhost -p 8000 -c-1 ./app",

    "start": "node ./app/Server/app.js"
}

But then the http-server wouldn't launch for some reason (although NodeJS worked fine). I also tried appending && node ./app/Server/app.js in the first start, but the same occured.

What am I doing wrong here?



via MortenMoulder

No comments:

Post a Comment