简体   繁体   中英

How to pass parameters to node.js from Windows command line

I'm working in a node application that can be started like this from a Mac machine:

DEBUG=app.* ENVIRONMENT=local node server/index.js

However, when trying to run that script in a Windows command line, I get the following message:

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

When running the script without the parameters, I don't get any error.

How can I pass said parameters to my index.js from Windows?

Run this in the CMD window where you'll run your node app.

SET DEBUG=app.*
SET ENVIRONMENT=local
node server/index.js

Or if you want it to be in a single line, type this.

SET DEBUG=app.*&&SET ENVIRONMENT=local&&node server/index.js

To make this variable changes persistent, you should edit your environment variables in control panel.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM