简体   繁体   English

在生产中运行mean stack app

[英]Run mean stack app in production

I am just playing with MEAN stack but I can't figure out how to run my app in production mode to perform some benchmarking. 我只是在玩MEAN堆栈,但我无法弄清楚如何在生产模式下运行我的应用程序来执行一些基准测试。 Site mean.io says: 网站mean.io说:

To run with a different environment, just specify NODE_ENV as you call grunt: 要在不同的环境中运行,只需在调用grunt时指定NODE_ENV

 $ NODE_ENV=test grunt 

How can I pass the variable to grunt? 如何将变量传递给grunt?

Edit: I am using Windows 编辑:我正在使用Windows

To decide if the application runs in production or development mode, it checks the NODE_ENV environment variable, which is a variable that you'll set in your shell and that will be read from node. 要确定应用程序是在生产模式还是在开发模式下运行,它会检查NODE_ENV环境变量,该变量是您将在shell中设置并将从节点读取的变量。

If you want to run grunt in production mode, use: 如果要在生产模式下运行grunt ,请使用:

$ NODE_ENV=production grunt

which will set the variable only for this execution . 这将仅为此执行设置变量。

If you want to permanently set NODE_ENV , use export : 如果要永久设置NODE_ENV ,请使用export

$ export NODE_ENV=production
$ grunt

On your production server, you can then edit .bashrc with this line to permanently set NODE_ENV . 在生产服务器上,您可以使用此行编辑.bashrc以永久设置NODE_ENV

For further information, you can read this blog post . 有关详细信息,请阅读此博客文章

Edit: On Windows, use set NODE_ENV=production on the command line. 编辑:在Windows上,在命令行上使用set NODE_ENV=production See this relevant question to know how to permanently set this variable. 请参阅此相关问题以了解如何永久设置此变量。

The following command works in my case: 以下命令适用于我的情况:

grunt prod

Notice that I use mean.js version 0.4.2 and found this config in file $HOME_PROJECT_FOLDER/gruntfile.js 请注意,我使用mean.js版本0.4.2并在文件$HOME_PROJECT_FOLDER/gruntfile.js找到此配置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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