I failed to make my node app work in WinSCP. To my understanding, node version 6 is installed on the server, while my node version is at at 8+. Does it matter? I also got e.g. express, mongoose and handlebars in my app. Do I need to add those in the server as well?
What are the proper steps to upload a node app?
On the server, you should have node install the app. This way node will download and install the files/libraries that are required in your package.json file on the server.
try this.
Upload your project to the server and change to the directory of your project. if node_modules exists delete the folder then run.
npm install
This should create a node_module folder and install all the requirements.
Once the install is complete you should be able to run your app with.
npm start
Related
I am new angular2 development, and what i came to know is before starin the angular2 development, I must install the nodejs for server and npm to download dependencies from official documentation.
I succesfully deployed the source code in tomcat sever[by build]
So my Question is after installation and creating the new project, i got node_modules. By using these node_modules(can i start development of angular2 on another i.e a new machine where node & npm is not installed)
Basically my question is.. I want to start development of angular2 by using the project structure on new machine. Without the installation on node & npm
From Angular docs
Node.js and npm are essential to Angular development.
If you built/compiled the app and have all the modules installed (you have your node_modules) folder then its just javascript and html which you can run on any server you want.
For npm, if you need any modules/packages, I think you can manually download the package and add it to your development environment. But what if the process needs to be automated? You can't just sit there and download all the packages from github. So npm is really helpful when it come to this. You only need a file containing all dependencies, and run it at build time (package.json)
About nodejs, nodejs allows you to run javascript on the server when you need any interaction with the database. So why don't we just go with the easy way?
I have to create a zip file of my whole nodejs server app.
I should be able to unzip it and run it, without installing dependencies and apps.
It should not be a binary file.
The dependencies should be flattened.
How to do this thing ?
Generally, a Node.js app has its dependencies installed in the node_modules directory in the project root.
So, after running npm install (or npm install --production), you should be able to zip up the project directory and that should be all you need.
If any of your dependencies in node_modules are native addons, then you will not be able to install them on a different architecture or OS. If there are native addons, you will also want to make sure your target machine has the same version of node installed as the machine where you created the zip file. (It's a good idea anyway, if you can, to make sure the node version on the target machine is the same as the source machine.)
One obvious requirement of the target host if you do as I describe above is that node is already installed there. Not sure if that's OK for your use case or not, but sounds like it probably is?
Thank you, all of you for your help.
I got the solution for my question.
I am using npm pack to pack the nodejs app.
To pack nodejs app with some dependencies like morgan, express we need to use npm bundle it helps to include the other module required for node js app.
With this, we don't need to perform npm install.
We just have to install bundle and then include bundleDependencies field including the name of required module in package.json.
And then perform then run the command npm pack. It will create a tar file just copy this file in other folder and uncompress it and run the server starting file.
The place where you are going to run the nodejs file, there nodejs app should be installed
I think you might be looking for this: https://github.com/nexe/nexe
Nexe is a command-line utility that compiles your Node.js application into a single executable file.
Example here http://clevercontent.org/keystone/signin
How should i deploy it properly?
There was a problem with RAM on my server on DigitalOcean. I don't have anough RAM to successful npm install. So i make npm install on local machine and moved node modules on server.
DON'T DO THIS
npm install must to be run on server. Because your node.js libs should be compiled by same C++ library.
So i extend SWAP on server and this is solve problem with npm install
This may be a silly question but I have installed node on my computer and have been running tasks for creating my sass which means I have a node_modules folder within my project folder and I'm wondering if I need to upload the node_modules folder to my live server or not?
Tipically you must:
To have installed Node.js in the server (and npm).
You generate packaje.json in local. npm init. You execute this in a folder containing node_modules.
When package.json is generated. You upload it to the server.
When package.json is in the server, specifically in your project folder, you install all dependencies with npm install
You should make sure that your server had installed node.js if you want to run node.js project on your server and you can use 'npm install' to install the modulars of the package.json.
Is it possible with NPM to manage the same dependencies for backend and the client-side scripts? I'm building a node.js application with express. When installing all dependencies, those scripts are installed into the node_modules folder. Is it possible to somehow tell express that it should look in those folder for javascript files for the client? E.g. when the client requests the file underscore.js, it should return the file from the installed module. Or is it possible to hook in to the npm installation procedure so that some files can be automatically copied to the public folder of the application?
You can hook into NPM after it installs the packages required by your application using postinstall in the scripts field in package.json:
install, postinstall: Run AFTER the package is installed.
For more read here: http://npmjs.org/doc/scripts.html