如何在本地生成grunt的生产模型中运行Mean.JS

时间:2021-06-23 01:07:50

Question 1:

I cloned latest mean.js package from the official Github repository, and went through the official document step by step. Now I am able to run the mean.js with grunt command on my machine. However, the application is running in development model. Even I run it with this command:

我从官方Github存储库中克隆了最新的mean.js软件包,并逐步完成了官方文档。现在我可以在我的机器上使用grunt命令运行mean.js了。但是,应用程序正在开发模型中运行。即使我用这个命令运行它:

NODE_ENV=production grunt

Still, the output of this command is below (same as grunt only):

仍然,此命令的输出低于(仅与grunt相同):

Specification Management - Development Environment
Environment:                        development
Port:                               3000
Database:                           mongodb://localhost/mean-dev
App version:                        0.0.1
MEAN.JS version:                    0.4.1

Does anybody know how to run it in production mode locally?

有人知道如何在本地生产模式下运行它吗?

Question 2:

I deployed this application to heroku. I can tell from the log that the application runs in production mode. However, there is only a blank page, same as problem in this post: Blank page on Heroku - mean.js angular app. I followed the question by adding grunt build before run it, but it doesn't work.

我将此应用程序部署到heroku。我可以从日志中看出应用程序在生产模式下运行。但是,只有一个空白页面,与此帖子中的问题相同:Heroku上的空白页面 - mean.js angular app。我在运行之前通过添加grunt构建来跟踪问题,但它不起作用。

Please help!

2 个解决方案

#1


2  

Answer 1: I have found the way to run an application in production mode. The command is

答案1:我找到了在生产模式下运行应用程序的方法。命令是

grunt prod

Answer 2: The official Mean.js repository added public/dist folder in .gitignore file. That's why the compiled JS files were not uploaded to Github, and so Heroku cannot get them from my repo. After delete the entry from .gitignore file, everything goes great.

答案2:官方的Mean.js存储库在.gitignore文件中添加了public / dist文件夹。这就是为什么编译好的JS文件没有上传到Github,所以Heroku无法从我的回购中获取它们。从.gitignore文件中删除条目后,一切都很顺利。

#2


0  

Regarding Answer 2: I had this same issue. Your solution will work great, however if you have to deploy frequently (as I do), it becomes tiresome to remember to constantly rebuild your compiled JS files. Instead, you can set it up as a build script post install hook, which heroku will read as part of the normal build process. In this way, it can run the same minification grunt jobs on heroku itself. The way I've done it is fairly primitive - you could tidy it up and just run the JS minification, rather than the full build...but you get the idea. Modify package.json 'scripts' node with the following:

关于答案2:我有同样的问题。您的解决方案将运行良好,但如果您必须经常部署(就像我一样),记住不断重建已编译的JS文件会很烦人。相反,您可以将其设置为安装后挂钩的构建脚本,heroku将作为正常构建过程的一部分进行读取。通过这种方式,它可以在heroku上运行相同的minification grunt作业。我做的方式是相当原始的 - 你可以整理它,只是运行JS缩小,而不是完整的构建......但你明白了。使用以下命令修改package.json'scripts'节点:

  "scripts": {
    "start": "grunt",
    "test": "grunt test",
    "postinstall": "bower install --config.interactive=false && grunt build"
  },

#1


2  

Answer 1: I have found the way to run an application in production mode. The command is

答案1:我找到了在生产模式下运行应用程序的方法。命令是

grunt prod

Answer 2: The official Mean.js repository added public/dist folder in .gitignore file. That's why the compiled JS files were not uploaded to Github, and so Heroku cannot get them from my repo. After delete the entry from .gitignore file, everything goes great.

答案2:官方的Mean.js存储库在.gitignore文件中添加了public / dist文件夹。这就是为什么编译好的JS文件没有上传到Github,所以Heroku无法从我的回购中获取它们。从.gitignore文件中删除条目后,一切都很顺利。

#2


0  

Regarding Answer 2: I had this same issue. Your solution will work great, however if you have to deploy frequently (as I do), it becomes tiresome to remember to constantly rebuild your compiled JS files. Instead, you can set it up as a build script post install hook, which heroku will read as part of the normal build process. In this way, it can run the same minification grunt jobs on heroku itself. The way I've done it is fairly primitive - you could tidy it up and just run the JS minification, rather than the full build...but you get the idea. Modify package.json 'scripts' node with the following:

关于答案2:我有同样的问题。您的解决方案将运行良好,但如果您必须经常部署(就像我一样),记住不断重建已编译的JS文件会很烦人。相反,您可以将其设置为安装后挂钩的构建脚本,heroku将作为正常构建过程的一部分进行读取。通过这种方式,它可以在heroku上运行相同的minification grunt作业。我做的方式是相当原始的 - 你可以整理它,只是运行JS缩小,而不是完整的构建......但你明白了。使用以下命令修改package.json'scripts'节点:

  "scripts": {
    "start": "grunt",
    "test": "grunt test",
    "postinstall": "bower install --config.interactive=false && grunt build"
  },