J
J
jeruthadam2017-09-01 15:21:52
Node.js
jeruthadam, 2017-09-01 15:21:52

How to pass variable to npm script?

I want to be able to change the server port either by specifying it in the package.json script or by running a command. I have this on a server npm script runs anyway on 3090
app.set('port', process.env.PORT || 3090)
"api": "nodemon api/server.js --PORT=7777"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Ukolov, 2017-09-01
@jeruthadam

"api": "PORT=7777 nodemon api/server.js"

I
Ivan, 2017-09-01
@LiguidCool

And also you

process.env.PORT
, i.e. the port can be set from the environment.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question