问题描述
如何运行:ng serve --prod
与pm2?
How can I run:ng serve --prod
with pm2?
ng来自Angular2的angular-cli服务.我正在DigitalOcean上运行.
ng serve from angular-cli, Angular2. I'm running on DigitalOcean.
我尝试在ng build --prod
当我从域 https://www.unibookkh.com/请求时,出现404错误:(我已经设置了nginx来监听端口4200.
When I request from the domain https://www.unibookkh.com/, i got 404 error: (I've already setup nginx to listen to port 4200.
我使用http服务器进行测试,因为我想我可以通过此命令运行pm2pm2 start my_app_process.json
其中
I test with http-server because I think I maybe can run pm2 through this commandpm2 start my_app_process.json
where
my_app_process.json
{
"apps": [
{
"name": "angular",
"cwd": "~/angular2",
"args": "-p 4200 -d false",
"script": "/usr/bin/http-server"
}
]
}
关于如何使其与PM2一起使用的任何更好的主意?
Any better ideas of how to get it working with PM2?
推荐答案
此命令将按预期运行:
我运行后
ng build --prod
然后在dist/文件夹中运行以下命令
then run the following command in the dist/ folder
pm2 start /usr/bin/http-server -- -p 8080 -d false
我找到了一个更好的解决方案:which ng
然后它将打印/usr/bin/ng然后输入
I have found a better solution:which ng
then it will print /usr/bin/ngthen type this
pm2 start /usr/bin/ng -- serve --prod
这篇关于如何使用Angular-Cli运行PM2? -Angular2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!