Node and npm with FTP - node.js

I have an issue with my application(a chatbot made with Vite/Node.js). When I run the command: npm run dev in the terminal inside vscode, I can open the localhost and use the application. But when I try to upload the files to my ftp server, and then open the website to run the applicaton, it does not work. I have looked for hours, and found out that the reason for this issue, is that my ftp server, does not have node.js and npm installed. So I guess my question is. How do I install node.js and npm on my ftp server, so that I am able to run this "npm run dev" command on the server? Btw, I am a beginner developer, with under 1 year of experience.

This is a pretty board question. But as you have discovered you can not use node on websites that are statically hosted. You can only use javascript, CSS, and HTML.
If you want to have a server, node running with a framework like express, then you need to host the server. But that is a giant topic, you could google it; there are many ways to host a back end service that is running node. (for instance an EC2 container on AWS)

Related

Configuring a server to serve a vue app [duplicate]

This question already has answers here:
Which command do I use to generate the build of a Vue app?
(19 answers)
Closed 4 years ago.
I think I have a bit of a mess here. I have my vue app running in my localhost environment. I want to deploy to a server I have hired. Which are the steps to accomplish this?
I have installed nodejs and npm on the server. At a first glance I tried to go the way I always did when using php, running nodejs app through apache server but it seems it is not the best option from what I read. In my local machine I run:
npm run serve
to start a server to run my vue app locally. Should I do same thing on my remote server? Are there better options?
Should I do same thing on my remote server?
Definitely no.
Notice in your package.json file you should have a script called "build", i.e. you can execute it with the command:
$ npm run build
Once executed, it should compile your Vue project and place the resulting files in a dist folder at the root of your project.
Notice that these files are plain HTML, JS (for browser, since Vue is only for front end) and CSS (plus any of your project assets if applicable).
Since you are familiar with PHP, you should know what to do with those files. Should your project be "simple" and not require backend services (like AJAX, REST, etc.), you can actually serve them on a simple server (no need for PHP, Node, etc.).
Otherwise, you should have plenty tutorials and resources online explaining how to publish those files on a simple server.

How to access Bluemix application's runtime shell as root?

I have a Nodejs application running in Bluemix. I try to run a command to install dependencies in Nodejs application container. I accessed it using application's runtime SSH. I need root privileges to install dependencies. It is asking me password for sudo command. How can i get that password?
You shouldn't be installing dependencies this way. The ssh terminal is intended for debugging purposes only:
If you need to troubleshoot an instance of an app, you can gain SSH
access to the app using the SSH proxy and daemon.
For example, one of your app instances may be unresponsive, or the log
output from the app may be inconsistent or incomplete. You can SSH
into the individual VM that runs the problem instance to troubleshoot.
Source: https://docs.cloudfoundry.org/devguide/deploy-apps/app-ssh-overview.html
NodeJS dependencies can be installed by adding a package.json file:
Cloud Foundry expects a package.json in your Node.js app. You can
specify the version of Node.js you want to use in the engine node of
your package.json file.
In general, Cloud Foundry supports the two most recent versions of
Node.js. See the GitHub Node.js buildpack page for current
information.
Source: https://docs.cloudfoundry.org/buildpacks/node/node-tips.html

Deploying nodejs to amazon

I'm new with NodeJS and have worked lately with a project which run in NodeJS. This project is actually going to be put online. The server runs on Amazon and is now running an "old" version of the project.
I've had a very fast manual how to deploy, but I didn't get it.
What I got:
Install cygwin (already did)
tar the project without the .git directory in cygwin
Upload the tar to the server in cygwin
Restart the application
Does anyone know a good tutorial or can someone explain to me how I do best? I know that there is no auto deployment.
I recently setup a nodejs application on AWS, the tools that i used was
nginx server for handling my http request, as starting nodejs in terminal is very problematic.
pm2 for auto restarting nodejs in case if error occur
git for version control, maintained a repo of my code and clone it to my AWS server
SSH for remote login
Hope this helps :)
I'm actually in the same process of deploying a node server via amazon aws. I personally started with watching some Videos to get a clue about AWS EC2, S3 and so on. The following link is a good start for understand some conecpts:
https://www.youtube.com/watch?v=jLVPqoV4YjU
afterwards it is best to read the documentation (better not all of it just the things you need and want to understand).
I also use pm2, git and maybe will use nginx also as reverse proxy ...

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.

How to use simple npm-install in Openshift?

I'm trying to use cute-files on my openshift account
https://www.npmjs.com/package/cute-files
I know node.js works as I did in localhost:3000 but not as expert,
I'm ended up with http://cutefiles-powerupware.rhcloud.com/ that's not I'm looking it. It should be Cute-files app as start.
I did PuTTY to access terminal to do npm-install but no luck due to permission.
The problem is... I cannot understand how openshift works, I need to know how to access console to do npm-install then, execute "$ cute-files", alternativley I've used Git to commit and push, the files are updated...I got no results... I've spent like 6 or 7 hours, Openshift has been very complicated me to use, can anyone explain how to install and execute simple node.js app in openshift?
It's not like you can access Openshift and run any command. Openshift isn't a simple hosting or vps service, it's a PaaS. That means they offer you an environment to run certain services in particular as you demand.
When you create an app it's bound to a git repository which when pushed will be deployed to openshift.
About your application being deployed and runned, it's NOT about node.js running in port 3000. Openshift has some default application file names and port to expect.
So, working in a local clone of such repository you might perform the npm install command, that will download the node_modules folder to be there.
How to do all this?
First you should install rhc in your system.
Manage to clone any of you applications via rhc.
Make changes, and do git.
Those changes may include doing npm install getting your dependencies.
When doing git push, expect the changes to be deployed.
You really should read this guide.

Resources