Is it a good idea to use NodeJS terminal or iisnode - node.js

I have micorosoft windows server 2012 r2 and I have nodejs as web and api server and I want to deply it in production mode. But my question is should i install forever npm module and set to production mode and run via command prompt and may be write .bat file to execute on start up or iisnode is a better idea.

I think that iisnode is a better idea.
Host using IIS is better than let a nodejs prompt always opened, running your server, with a danger of someone close or do something that you don't want.
I always use iisnode and is very simple, look at Github page.

Related

How to properly run NodeJs on Windows Server in production

I am having difficult times, trying to make my NodeJS scripts run on windows server 2012. Or more precisely, to make it robust.
I have installed PM2, whic his great, also added service for windows startup which works fine, but now I found biggest issue I can't solve.
When windows server user start pm2 start, directly on server or through ssh, when logging out, all pm2 scripts are gone.
I've tried to look into pm2-windows-service but that seems inconsistent, when I restart service, it works fine, but sometimes I need to manually reload o restart only 1 script and then whole list of pm2 scripts gets somehow detached or attached to user, so when I log out from server it's all gone again.
I can't find solution to have watcher/autorestart on scripts, and make them run as a service regardless of user being logged in/out.
There must be solution for running multiple nodejs scripts on windows ?
Once you launch your NodeJS processes, you should run pm2 save command. That way, your stated scripts are saved.
Your attached/dettached problems may be due a relative path configuration in the service env variables. Try moving to an absolute path.
Note: PM2 recommendation is to launch commands with an admin-privileged user; otherwise inconsistences may appear.
Note (2): Bare in mind that PM2 on Windows has some issues. For example, if you restart your server, most of the times processes dissapear from pm2 ls (they noted that Windows does not have the feature to restore saved instances). If you saved them, pm2 resurrect will restore them.

How to run React Web Application forever

I have created a web application using React framework. I am able to Run it in localhost using npm start command.
I have a server in AWS ubuntu 14.04. I have uploaded all code there and run the application using npm command. It is working well. But if i close the terminal then it has been stopped. I know we need to run that instance or service. But how can we do it forever without any UI of ubuntu?
Did you link the public directory's file(HTMl/PHP file) to your dedicated host server?
If not, Look to do how to setup it with AWS in local you can do it with virtual hosting. I'm sure in AWS there'll be any same way to do.
You can use a library called forever which will keep the process running in the background.
https://github.com/foreverjs/forever

Node.js Command Prompt Issue

I don't believe this behavior is correct at all, but please correct me if I'm mistaken. So I have an Angular 2/Ionic 2 app created all through the Node.js command prompt... the commands all work fine, up until I execute ng serve, after that I can't type at all into the command prompt. Only way I can type is if I close out of the command prompt and restart (less than ideal). Is this normal behavior? Or only occurring on my machine?
ng serve launches a basic web server for you using which your static files are served. It also listens for updates to your project files and if any changes are detected it bundles the project again and reloads the browser tab automatically. So it's important that it keeps running when you're developing your application.

Missing file or plugin on freshly installed Cloud9 ide?

I'm currently trying to set up cloud9 on my debian server for node.js development. I followed some simple steps as described below, but there seems to be missing something and I would like to know how this can be resolved in the best way. Of course, I could start looking for the missing file on the web and put it there, but I think that's not the way to go.
What I did is this:
ssh'ed into my Debian server into my home folder
sudo git clone https://github.com/c9/core.git sdk (completed succesfully)
cd sdk
sudo ./scripts/install-sdk.sh
The installation finishes like this:
Success!
run 'node server.js -p 8080 -a :' to launch Cloud9
When I then start up the IDE with this command:
node server.js -p 1234 -l 0.0.0.0 -a rob:mypass -w /home/rob/myproject/
...everything looks good:
Starting standalone
Connect server listening at http://x.x.x.x:1234
Using basic authentication
CDN: version standalone initialized /home/rob/sdk/build
Started '/home/rob/sdk/configs/standalone' with config 'standalone'!
Cloud9 is up and running
and I can basically reach the IDE from my local browser. The problem is that it stops on the welcome screen with this loading indicator in the middle right under the cloud9 logo. The JS console shows a missing file (I've replaced my real URL):
http://myserver.de:1234/static/plugins/c9.ide.collab/notifications/bubble.js Failed to load resource: the server responded with a status of 404 (Not Found)
I then looked into the folder /home/rob/sdk/plugins/c9.ide.collab/, but it is empty.
What am I missing? Do I need to install something with npm or do I have to change the package.json file somehow? I'd really appreciate some help because I think wildly modifying and copying in files won't make things better.
edit: It turns out it was "bug in the script updating references [of some plugins]". Details: https://github.com/c9/core/pull/365
—Cheers!
Original answer:
I think think the c9.ide.collab plugin's refspec is wrong here: https://github.com/z3cka/core/commit/5f45ea38f422160a0030c5ef8d1efb19231bc78c#diff-b9cfc7f2cdf78a7f4b91a753d10865a2
I changed it back to #54aa1cbee0, ran the install-sdk.sh and it grabbed the latest version of the collab plugin. While prepping a PR, I just found 3 more plugins with bad refspecs
c9.ide.language
c9.ide.language.javascript.eslint
c9.ide.run.debug
I'm currently working on a fix for the rest of these.

is it possible to learn node.js without access to cmd.exe?

My company has locked down access to CMD.EXE (not sure why)..
I am futtzing around with Node.JS, installed it via the official Windows installer but found I have 0 access to cmd.exe and now I am wondering if I can even go about learning it with the Node terminal only?
Simple things like node -v do not work in the terminal. You have to actually do process.version.
I want to install express as another example and it does not work either.
npm install -g express-generator
Is there another keyword to use in place of npm when using Node.js Terminal?
Also when the Node.js terminal stops at ... is Ctrl-D the only option to break?
They allow you to run installers, but block access to cmd.exe? That is odd, but there are some more options.
Have you tried Powershell? If cmd.exe is blocked, they might have also blocked Powershell.
Install a third party console. Something like:
console
ConEmu
PowerCmd
Use an IDE with built in support like WebMatrix
Install Node on a remote server that you can SSH into (using Putty or similar tools).
Free AWS Micro Instance
$150 / month free on Azure if you can qualify as a startup.
Cheap hosting with Digital Ocean
Free VPS with 5Jelly (Never used them, can't vouch for quality)
Ask your tech department for access (should probably be #1 :)
When you just double-click on or execute just "node.exe" at a command prompt, you get the REPL, which is an environment that allows you to execute javascript code. It's not a regular command prompt.

Resources