How can I set NODE_ENV=production on Windows?

0 votes

In Ubuntu it's quite simple; I can run the application using:

$ NODE_ENV=production node myapp/app.js

However, this doesn't work on Windows. Is there a configuration file where I can set the attribute?

Jul 13 in Node-js by kartik
• 20,980 points
152 views

1 answer to this question.

0 votes

Hello @kartik,

It would be ideal if you could set parameters on the same line as your call to start Node.js on Windows. Look at the following and run it exactly as stated:

You have these two options:

  1. At the command line:

    set NODE_ENV=production&&npm start

    or

    set NODE_ENV=production&&node index.js
  2. The trick for it to work on Windows is you need to remove the whitespace before and after the "&&". Configured your package.json file with start_windows (see below) below. Then Run "npm run start_windows" at the command line.

    //package.json
    
    "scripts": {
      "start": "node index.js"
      "start_windows": "set NODE_ENV=production&&node index.js"

Hope it helps!!

Thank You!!

answered Jul 13 by Niroj
• 44,800 points

Related Questions In Node-js

0 votes
1 answer

How can I get npm start at a different directory?

Hello @kartik, Try using: npm start --prefix path/to/your/app & inside ...READ MORE

answered Jul 14 in Node-js by Niroj
• 44,800 points
75 views
0 votes
1 answer

How can i get the extension of the image in node.js?

Hello @kar You can do the following to ...READ MORE

answered Jul 16 in Node-js by Niroj
• 44,800 points
16 views
0 votes
1 answer

How can I use an http proxy with node.js http.Client?

Hello @kartik, You can use request, I just found ...READ MORE

answered Jul 17 in Node-js by Niroj
• 44,800 points
60 views
0 votes
1 answer

How to get GET (query string) variables in Express.js on Node.js?

Hello @kartik, Since you've mentioned Express.js in your ...READ MORE

answered Jul 8 in Node-js by Niroj
• 44,800 points
47 views
0 votes
1 answer

jQuery AJAX fires error callback on window unload - how do I filter out unload and only catch real errors?

Hello, In the error callback or $.ajax you have three ...READ MORE

answered Apr 27 in Java-Script by Niroj
• 44,800 points
85 views
0 votes
1 answer

How do I pass command line arguments to a Node.js program?

Hello @kartik, If your script is called myScript.js ...READ MORE

answered May 5 in Java-Script by Niroj
• 44,800 points
147 views
0 votes
1 answer

Error:Issue when trying to use IN() in wordpress database

Hello @kartik, Try this code : // Create an ...READ MORE

answered May 8 in PHP by Niroj
• 44,800 points
45 views
+1 vote
1 answer

How do I debug Node.js applications?

Hello @kartik, Use node-inspector  from any browser supporting WebSocket. Breakpoints, ...READ MORE

answered Jul 8 in Node-js by Niroj
• 44,800 points
32 views
0 votes
1 answer

How can I update npm on Windows?

Hello @kartik, To update NPM, this worked for ...READ MORE

answered Jul 13 in Node-js by Niroj
• 44,800 points
62 views
0 votes
1 answer

How can I pretty-print JSON using node.js?

Hello @kartik, JSON.stringify's third parameter defines white-space insertion ...READ MORE

answered Jul 12 in Node-js by Niroj
• 44,800 points
46 views