如何在OS X中将NODE_ENV设置为生产/开发 [英] How to set NODE_ENV to production/development in OS X

查看:138
本文介绍了如何在OS X中将NODE_ENV设置为生产/开发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用于express.js环境。有什么建议吗?

For use in express.js environments. Any suggestions?

推荐答案

在运行您的应用程序之前,您可以在控制台中执行此操作,

Before running your app, you can do this in console,

export NODE_ENV=production

或者如果你在Windows中你可以试试这个:

Or if you are in windows you could try this:

SET NODE_ENV=production

或者你可以像这样运行你的应用程序:

or you can run your app like this:

NODE_ENV=production node app.js

您也可以在js文件中设置它:

You can also set it in your js file:

process.env.NODE_ENV = 'production';

但我建议不要在运行时文件中执行此操作,因为打开它并不容易服务器中的VIM并将其更改为生产。您可以在目录中创建config.json文件,每次运行应用程序时,都会从中读取并设置配置。

But I don't suggest to do it in your runtime file, since it's not easy to open up VIM in your server and change it to production. You can make a config.json file in your directory and everytime your app runs, it reads from it and sets the configuration.

这篇关于如何在OS X中将NODE_ENV设置为生产/开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆