How can I prevent multiple applications being served at once by AngularCLI? - javascript

Using
Angular CLI: 1.5.2
Node: 6.10.1
in a Mac OS Sierra,
I have installed several web applications so far. Anytime I do ng serve. All of the applications that I have installed in the past are served.
I guess it's the normal behavior. But I don't need that...
How do I "uninstall" old applications that I don't want anymore to be run?
Edited to answer comments:
I run npm start from one of the applications that get served. Actually, I run it from the only application that I'd like to be started. However, as I said, all of the applications get started up.
Some other facts:
They run under the same port (4200).
The first application I installed runs without any context in the URI. (http://localhost:4200)
The rest of the applications are started under the same 4200 port, but I need to complete the URI with the actual context.

Related

How to deploy Javascript app that runs from command line?

I have a simple CLI application written in Javascript using Node that is for internal use by a small team. It runs in the Linux terminal as a CLI app. The app consists of a single ".js" file and requires a few Node packages. The problem I face now is how to deploy it to our internal team using a simple method that fits with our routine process of keeping end user computers updated.
Our app needs to be installed once per workstation / laptop and to be available to all users on that computer. Any user should be able to open a terminal and enter the command to run the app.
It seems a lot of people have discussed using Javascript for shell programming, but this issue of deploying the completed app is not widely discussed. I have not found anything on the topic. So far I have been recommended solutions that are appropriate for either development environments or web servers.
This app is not a web app and it is not deployed on a server. It needs to run offline. I am also not asking about developing or maintaining the app on a development workstation.
The installation process should ideally be as about simple as installing a shell script in /usr/local/bin and setting permissions so all permitted users on a computer can run it. We are looking for an installation method like this:
copy the Javascript file only once to each computer (to a location on the $PATH) and make sure the Node packages are available globally on that computer.
I specifically want to avoid having to do an npm install for each user account on each computer.
I also want to avoid having to update Node packages for each user account on each computer.
A developer will keep the app updated so it is always compatible with the latest version of the Node packages, and all computers it is deployed on will always have the latest versions of those packages installed.
One specific problem I encountered is discussed here, but the answers assume a different set of requirements (such as the need for "multiple applications running on different package versions").
For those requirements, if the actual problem is solving the EACCESS error (you should edit the question to include that information), then you should look at the permissions of all directories, and make sure that the user account that manages node packages on each computer has correct permissions.
One way to do that is to give /usr/local a special group, set the sticky bit with chmod (see man chmod), and use chgrp -R on the existing tree.
Then make the installing account a member of that group, and don't use sudo for npm install -g.
(Never using sudo for installations into /usr/local has the additional advantage that you can't accidentally install something somewhere else, for example because you didn't set paths in this local package source correctly.)
We are using these two approaches for similar deployments:
the programs live on a specific network mount. All users can run the same package from there. The developer only updates this package. No copying to local machines.
we use a simple deployment script which runs on all machines on logon. It pushes and copies the latest version to the local machine.

Node.js app cluster load balancing using PM2 on Windows

Node.js version: 4.5.0 - PM2 version: 2.0.18
I have an in-house Node.js app under test. I'm using pm2 for clustering and I assumed it will take care of load balancing. BUT when I ran my app on Windows and looking at the processes (using pm2 monit command) I cannot see even distribution of load. Sometimes one process spike to 70% and the other are not doing anything.
So, I think the load balancer of pm2 mechanism is at fault. I read somewhere that Its not using round robin on windows machines?
Could someone share their experience about this issue.
Also, I thought maybe Nginx is another solution to configure it as a load balancer in front of the pm2 Node.js cluster but not quite sure about the configuration

Requirements to run Node.js on server

What type of server/service type supports Node.JS applications?
Is we need to install node/npm on server.
Does it need to be a dedicated server?
Thank you in advance.
I don't think you need anything special, even a random Raspberry PI with linux can host NodeJS app.
Since node.js have executable on Linux, Windows and Mac, the hardware will not be limited by what can run node.js, but by what your script need, and the workload you expect.
If you run a basic website with little trafic, a RPi will be enought, if you were to port Facebook or Google to node.js, you would still need complete dataserver.
So the only limit is third party utilities and your own knowledge of the platform you use.
Node.js Application can be hosted on Linux,Windows or any other O.S. And for node.js Application there is basic minimum setup is required. like Node.js , git bash, npm etc.
you can follow this link

Node.js emits runtime error when listen to port 9999

I'm completely new to nodeJs, and just to learn step by step. I managed to download, run nodeJs via the CMD and tested by creating file, all works fine. The problem now is when I want to tell nodeJs to display the output on the browser instead. I simply followed the tutorial but I'm getting runtime error. I suspect the port is somewhat wrong. Which port no I should use here, is it my localhost port which is 80, I tried it to no avail.
Here's the error message:
Referred here:Using node.js as a simple web server
All I want is to be able to see the output in the browser via nodeJs. I think the port 9999 is meant for tcp connection as I'm learning for real-time app.
You're not using NodeJS to run your code. To run your code using NodeJS, run them with node:
node c:\projects\test\helloweb.js
The reason what you tried didn't work is that typing c:\projects\test\helloweb.js in cmd.exe and pressing Enter will not run the code in a browser, or in NodeJS. It will try to run it using whatever application you have associated with .js files. The Windows default, which is what your computer is using, is to use Windows Script Host (as you can see in your error message). WSH provides a runtime environment that's quite different from NodeJS and quite different from a browser.
If you read the dialogue carefully you'll see its title is "Windows Script Host", not Node. In fact Node is a command-line tool that doesn't launch dialogues or other widgets. Your screenshot clearly shows you were doing it just fine and then eventually forgot to type node in your command:
FYI, Windows Script Host is a tool that's similar to Node (a server-side ECMAScript engine) but belongs to another vendor (Microsoft), uses a different ECMAScript implementation (JScript) and possibly hasn't been updated in 10 years. That means that features and available libraries are completely unrelated to those in Node.

Interactively debugging a Node.js application on Heroku?

My Node.js application runs correctly locally but it has errors once deployed to Heroku.
I cannot use node-inspector to debug as it requires three ports, and Heroku allows only one port.
https://discussion.heroku.com/t/how-to-debug-node-on-heroku-using-something-like-node-inspector/477/6
I cant use the debugger built into Node.js because I need a CLI to issue debugging commands.
http://nodejs.org/api/debugger.html#debugger_debugger
What is the best strategy for interactively debugging a Node.js application on Heroku?
Found One-Off Dynos, which allow:
Running a console (also known as a REPL shell) to run arbitrary code or inspect the app’s models against the live database. (e.g. rails console, irb, or node)
https://devcenter.heroku.com/articles/one-off-dynos#types-of-one-off-dynos
I didn't have time to test, but this should let me run the built in node debugger.

Categories

Resources