How to run the Nodejs server without commandline

2020-04-08 13:13发布

I want to deploy the nodejs files to web server, for the time being, i was run like this node server.js through command prompt. how to run the nodejs always and without command prompt. please suggest.

标签: node.js
1条回答
何必那么认真
2楼-- · 2020-04-08 13:57

To deploy node.js app, you pretty much need shell access. You have to run node.js somehow. So, typical web-host does not work, you need rights to run your own process. If you are running host yourself, then you are looking for process manager, for example supervisor or pm2.

There is some node.js hosting services too, some good ones listed here. All hosting providers give you instructions how to deploy node.js on their platform so I'm not going to cover that (some examples: Heroku, Digital Ocean). Especially Digital Ocean have a lot of good tutorials, worth of reading, even if you are using some other hosting.

That being said, are you sure you have Node.js app? Node.js is often used in client-side workflows too, so it's possible your app could be deployed using cPanel. If you are just using node.js to run webpack-dev-server, for example, changes are you have just client-side app and it can be deployed on regular http-server, like Apache. If that's the case, your build process most likely produce dist folder which contains html, css and js to upload to our server's document root.

查看更多
登录 后发表回答