簡體   English   中英

如何永遠使用 npm serve 運行?

[英]How to run npm serve using forever?

我的最終目標是使用 Shipit 自動化我的開發。 我可以正確地將代碼放在服務器上,但我無法讓命令NODE_ENV=production forever start -c 'npm run serve'正確執行。 當我嘗試在我的服務器上本地運行它時,這是我得到的響應(幫助輸出)。 我需要運行npm serve因為它運行以下內容: "serve": "gulp build && npm-run-all --parallel gulp-watch jekyll-serve" 我的項目是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:
...
...

如果永遠不起作用,您可以使用另一個選項,為了讓您的腳本文件始終在后台運行,您可以使用

下午2點

參考這個https://www.npmjs.com/package/pm2

或第二個選項是您可以使用

多路復用器

你可以使用它,它允許你像在本地系統上運行一樣運行 npm 服務,為你提供下面的鏈接

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

您需要為要提供服務的文件夾指定絕對路徑,還需要使用which來獲取命令絕對路徑。

我使用 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