nssm service is downloading but not serving my web pages - node.js

I'm deploying my node and express web application using nssm tool.
I've configured and installed my application as a service but when I navigate to
http://localhost:3000 the ./bin/wwww file is being downloaded instead of serving it.
My application is Node and Express. My startup file is app.js. I'm able to launch the application with the commands
npm start
or simply
nodemon
but cannot run the application using nssm. Can anyone help me what am I doing wrong?

I've switched to a different method.
qckwinsvc is simple and easy to use. I pointed the script path to my appdir\bin\www for this to work.

Related

Can someone tell me what is the build command for node js application?

I have created an API project with NodeJS and Express. Now I want to build the project and publish it to my IIS Server. Can someone guide me in the correct direction ?
You don't need to build a node.js app. You just need to run it with node.
eg node ./index.js
You don't need a web server to run a node.js app. Node is a server.
You can't build a node application, node is a server, you run it by running the index file, for production you simply run it and flag it as production.
This might help Hosting express node.js applications in IIS using iisnode. For more info on the project itself, you can find its repo here iisnode.

I can't start my NextJS js app using plesk

I'm trying to start a NextJS application on my Node server using Plesk but it is not working. I activated NodeJS for my Plesk environment, and I was able to run npm install and npm build, but now, when I try to start the application, Plesk only shows "Please wait" and stays like that with no change, I have been waiting for more than 2 hours now, but I don't get any results, no errors, nothing.
The only issue I can think of is that, according to what I could find, the Application startup file and the package.json file should be in the same directory, the root folder, but in my case this is not possible. I have my package.json in the root directory, but the startup file for NextJS, index.js, is inside the pages folder. I tested building and starting the app locally and everything works fine, I don't understand why it's not working with Plesk.
I was able to fix this after correcting the startup file, it should be "node_modules/.bin/next" and not "pages/index.js".
Also when you start your app, Plesk will tell you to wait. Just check the site and make sure it is running, if it is, you can close Plesk.
You might need to install Express in your Next.js
You may refer to this repo fmi # https://github.com/zeit/next.js/tree/canary/examples/custom-server-express
If you're referring to the package.json's command we'll have:
dev
build
start
In Plesk's Node Application extension.
Website & Domains > "Your Domain" > Enable Node.js
Simply set server.js as my Application Startup File.
Ensure that all dependencies is installed using "Npm Install" helper.
You must run build command before start command.
Screenshot:
Helpful NPM/Plesk reference:
Running scripts in Node.js Application
Adding .npmrc file in Node.js Application Root folder

How to run a webpack application forever on a remote CentOs 6.8 server

I am about to deploy my first application on a centos 6.8 remote server. Actually this application is a react.js client which uses webpack for packaging. I have been able to copy the project on the server with file zilla, and can only run the application with npm start which is translated to nodemon src/server.js --ignore components using putty. The issue in this method of running the application is that the application stops running when I close the ssh client. Is there another way of running the application for an indefinite period of time remotely?
Actually you shouldn't do that, because looks like you are trying to use webpack development server in production.
You must generate production build with webpack and serve generated files statically with any web server.

Run NodeJS command on Azure

I am fairly new to NodeJS development. I have no issues whatsoever running commands on my local machine. For instance, say I want to install a package called "formidable" on my Node server, I'd run the command 'npm install formidable'. If I have deployed my NodeJS application to Azure, how would I run the same command?
NB - I do not want to manually run the command on my local machine and then deploy to Azure. This will take far too long, since I have to install many packages each with many files in them.
Please advise on how I go about doing this?
Thanks
Beside login KUDU console site and run command in online cmdlet. You also can configure dependencies in package.json, then you deploy your nodejs application to Azure via GIT, it will automatically install the dependencies in this file.
For example:
You add the formidable module in dependencies:
Then deploy it application on Azure Web Apps, you can see the remoting deployment logs in cmdlet that the module was added in the application on Azure, e.g.:
You can refer to Create a Node.js web app in Azure App Service for how to create a nodejs application and deploy via GIT.
If you are running an Azure Web App you can use Kudu Services.
To do this
browse to http://yoursitename.scm.azurewebsites.net
It will ask you to authenticate if you have not already
Click on Debug Console -> CMD
You can run your npm commands from there.
Screen shot below
More information can be found here: https://github.com/projectkudu/kudu/wiki

How to deploy a socket.io from nodejs on Tomcat

Here's the thing, I have a folder, using Nodejs and socket.io(it's a chat) and I also have a server running Tomcat 8. I have worked with .war and .ear files before in Tomcat, but I'm new in this nodejs deployment thing.
Do you guys have like a tutorial or can you explain me how can I like package my app and then deploy it, or upload the folder, I don't know, something.
You don't need tomcat to run your node.js application. Just be sure node is installed on your server and the port you are using is allowed on your server's firewall and you are good to go. (Don't forget to install your npm packages through your packages.json of course)
Usually a node.js app is run like below;
node server.js
And that's all. If you'd like to keep it alive or restart in any case of issue you can use forever (https://www.npmjs.com/package/forever)
If you want to load balance with reverse proxy or if you want to configure ssl etc. you can use nginx or haproxy etc.
If you want to automate your deployment you can create a hook to your git source (github, bitbucket etc.) and write down a script to stop / start your node processes, fetch modified files, install npm packages etc.

Resources