Node.js is generally code running on the server; what role does it play in front-end project development? - node.js-client

Generally, when writing vue.js front-end projects, node.js is used. For example, npm installs some node.js three-party packages to node_modules/.
Excuse me, node.js is generally the code running on the server side; what role does it play in front-end project development? Is it just npm run dev to run the webserver like this?
Or can Node.js also write some front-end code? But Node.js is a program running on the server, how can you write front-end code?

First of all, Node.js is a runtime environment that can run JavaScript, which is similar to the JavaScript runtime environment embedded in the browser. In fact, Node.js is ported from Chorme's built-in V8 JavaScript runtime environment;
Then, Node.js can be used as a server, running the server. It can also be used as a scripting tool. Now the front-end package management and packaging tools are all Node.js scripts;
To sum up, the difference between front-end code and back-end code is: where does it run? The client (front-end) runs client-side code, and the server-side runs server (back-end) code.
Node.js is a runtime environment. There is no such thing as writing front-end or back-end code. It can be said that it runs front-end packaging scripts, and runs JavaScript server-side code. The JavaScript server can serve the front-end, such as server-side rendering.

Related

Why asp.net needs IIS(Internet Information Services) to run web server? How this works in nodejs?

If a web application is developed in Asp.net, IIS is needed to run a webserver.
How these two(Asp.net and IIS) works together? Do IIS takes the build files and runs the server?
How expressjs(A frame work of nodejs) run web server since it isn't using any other software?
I can explain the node.js side of things and hopefully someone else can come along and explain the IIS/ASP.net side of things.
Node.js is a generic Javascript run-time environment. You can build all sorts of apps in it, even applications that have nothing at all to do with a web server.
It so happens that one of the built-in libraries in node.js is an http/https server. So, if you want to build a node.js-driven web server, you just grab the http server object, create a server, start it and program away on request handling.
Express is a web framework that is built on top of the node.js http/https server objects. It uses the built in server and provides a framework around that for defining request handlers, setting up routing and middleware and the middleware API is supports enables all sorts of 3rd party libraries for doing a wide variety of web-server-type things such as authentication, encryption, compression, uploads, downloads, image handling, audio handling, video handling, etc...
What set node.js apart from a number of other web-server frameworks is that node.js didn't start out saying I'm only a tool for doing web server stuff. It started out as a generic programming environment that happened to have a pretty good web server built-in as one of the tools one could use. And, it only takes a few lines of code to create and start your own web server using the built-in support. I would hazard a guess that building web-server apps is perhaps the most popular thing to do with node.js, but certainly not the only thing.
For example, I have a node.js script I wrote that does nightly housecleaning on my disk drive. It removes certain types of files from my temp directory. It helps manage backup files (keeping only the last 10 backups of my Adobe Lightroom catalog). This use of node.js has absolutely nothing to do with a web server. It's just a Javascript run-time environment that I happen to use the file system access libraries in it to do a bunch of file management.
For example, here's code to start a basic web server in plain node.js:
const http = require('http');
const server = http.createServer(function(req, res) {
console.log("got a request from", req.url);
res.end("Hi");
});
// start web server on port 3000
server.listen(3000);

Deploy asp.net react template without nodejs dependency on IIS server

I'm having problems with deploying and running the ReactRedux template on an IIS server which doesn't has nodejs. The app was created using AspNetCore.SpaTemplates' "reactredux" option:
https://blogs.msdn.microsoft.com/webdev/2017/02/14/building-single-page-applications-on-asp-net-core-with-javascriptservices/
The app is the same as the template, no changes were made. We first tried to host it on IIS with nodejs installed on the IIS server, everything works fine:
screenshot with nodejs
But when we uninstalled nodejs from the server and restarted IIS, it wasn't working anymore:
screenshot without nodejs
We couldn't figure out what the error is because running it in development mode requires nodejs and when we run it with dotnet run in development mode the error message complains about node.js not being installed, as expected.
We tried to deploy the app running:
$Env:ASPNETCORE_ENVIRONMENT = "Production"
dotnet publish -c Release
and using Visual Studios build>publish interface.
Acording to the docs here, the app shouldn't need nodejs when its deployed for production:
https://learn.microsoft.com/en-us/aspnet/core/spa/react?tabs=visual-studio
Unlike the development build, the production build doesn't require
Node.js to be installed on the server.
I'm new to asp.net and deploying apps on IIS, maybe the solution is trivial but we couldn't manage to solve this, thanks in advance.
If you don't want any nodejs dependency, make sure you disabled server-side prerendering:
https://github.com/aspnet/JavaScriptServices/issues/932
If you're not doing server-side prerendering, then you will not need
Node.js on your production server, because all the JS will be executed
on the client side.
If you are doing server-side prerendering (which is the default in the
React-Redux template in this repo), then you do need Node.js on your
production server, because the prerendering process involves executing
your JavaScript code on the server.
To disable server-side prerendering do the following:
Remove asp-prerender-module="ClientApp/dist/main-server" from Views>Home>Index.cshtml
Remove #addtaghelper "*, Microsoft.AspNetCore.SpaServices" from Views/_ViewImports.cshtml

How do I run Meteor shell in Heroku?

I've deployed my Meteor app to Heroku using the https://github.com/jordansissel/heroku-buildpack-meteor buildpack. My Meteor is v1.0+.
How do I access a server console to my app? Normally on my local dev machine I would run $ meteor shell.
Similarly, how can I meteor reset?
Thanks
If you used the oortcloud meteor buildpack, or a fork of it, the build uses a production mode build of meteor. meteor shell is a development tool and not available for use in production mode.
This is a tradeoff. You could theoretically use use a development mode instance in production but you would have terrible performance. Meteor in development struggles to cope with > 10 users. In production mode the figure is much larger.
meteor reset on the other hand clears the database of the development mode database. To clear up your database log into your database using mongo and drop all the collections. Alternatively run use db.dropDatabase(); (in mongo)

gruntfile.js issues or minification issues

We are working on developing a website using different APIs naming Firebase, Filepicker etc. Technologies used are Node.js and AngularJS. The project is based on a tool called yeoman, which is a scaffolding tool for web apps. We keep our modules updated through bower and NPM. The website is developed and running fine locally. We are inclined to host the app on Heroku's server and whenever we push the production code the application breaks without any message and the server crashes. I believe there are some issues with Gruntfile.js or minification issues with angular when used with grunt. Please connect me with someone who could guide me to setup the website on Heroku's server. We use heroku toolbelt for windows to push the changes.
There are some known issues with minifying AngularJS app, some of the declarations need to be written in particular way. See this SO answer.
Also, read the docs, scroll down to the part "A note on minification".
I've found this when looking for Heroku + AngularJS issues.
Please also verify compression server settings you are using.

How to install FitNesse on application server as war/ear

Fitnesse download page only has option for standalone.jar and this is also what the instructions are for. Is it somehow possible to install FitNesse on a separate app server, such as Tomcat? There's not directly any war/ear to download, but can I bundle one somehow?
I'm experimenting with acceptance testing frameworks and need to run the tests on a very specific test environment, and thus require a possibility for installing on an already running app container where the tests are executed. Changes for getting even java executable from command line in this environment are slim, and if possible, the process would take probably months to realize.
I do not believe it is possible, but even if you were to get the wiki running inside an app server, a test run would still try to start a new java process (by starting the java executable) so you still need access to that executable.
But does the test environment really need to be in the app server? I usually use FitNesse to test an application from the outside: the test framework makes remote (http) calls to an application running in an app server, but it does not run in that same app server itself.

Resources