简体   繁体   English

如何永远使用 npm serve 运行?

[英]How to run npm serve using forever?

My end goal is to automate my development using Shipit.我的最终目标是使用 Shipit 自动化我的开发。 I can drop the code on the server properly, but I cannot get the command NODE_ENV=production forever start -c 'npm run serve' to execute properly.我可以正确地将代码放在服务器上,但我无法让命令NODE_ENV=production forever start -c 'npm run serve'正确执行。 When I tried running it locally on my server, this is the response I got (a help output).当我尝试在我的服务器上本地运行它时,这是我得到的响应(帮助输出)。 I need to run npm serve because it runs the following: "serve": "gulp build && npm-run-all --parallel gulp-watch jekyll-serve" .我需要运行npm serve因为它运行以下内容: "serve": "gulp build && npm-run-all --parallel gulp-watch jekyll-serve" My project is a fork of Tabler .我的项目是Tabler 的一个分支。

root@server:/var/www/server# cd /var/www/server/current/front-end/ && NODE_ENV=production forever start -c 'npm run serve'
help:    usage: forever [action] [options] SCRIPT [script-options]
help:    
help:    Monitors the script specified in the current process or as a daemon
help:    
help:    actions:
...
...

You can use another option if that forever doesn't work , for keeping your script file always running in background you can use the如果永远不起作用,您可以使用另一个选项,为了让您的脚本文件始终在后台运行,您可以使用

PM2 npm下午2点

refer this https://www.npmjs.com/package/pm2参考这个https://www.npmjs.com/package/pm2

OR second option is that you can use the或第二个选项是您可以使用

tmux多路复用器

you can use this and it allows you run the npm serve same as you run on local system providing you the link below你可以使用它,它允许你像在本地系统上运行一样运行 npm 服务,为你提供下面的链接

https://www.digitalocean.com/community/tutorials/how-to-install-and-use-tmux-on-ubuntu-12-10--2 https://www.digitalocean.com/community/tutorials/how-to-install-and-use-tmux-on-ubuntu-12-10--2

You need to specify the absolute path for the folder you want to serve, and also use which to get the command absolute path as well.您需要为要提供服务的文件夹指定绝对路径,还需要使用which来获取命令绝对路径。

I use npx to run serve instead of having it installed, and it works like this:我使用 npx 来运行 serve 而不是安装它,它的工作原理是这样的:

forever start $(which npx) serve -l 80 -s /home/user/folder/build/

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

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