ReastJS, Node, and IIS - node.js

I have been following a tutorial from Cory House on Pluralsight about React, Redux, webpack, babel, and a bunch of other support libraries. I am using Visual Studio Code on a windows OS. I have completed the tutorial, which includes a build process that outputs a bundled js file to a dist folder. The build process also runs the app to verify the build is correct (which it is). I then tried to copy the contents up to an IIS server and run it there. However, when I try to access the web site, the index page comes up blank. I verified the bundled js file is called (returns 200 status). That left me wondering if there is an extra step I need to do to transfer an app created using Node to one that can run on IIS.
I should clarify I added a web.config file to the site.
Any help is appreciated
Edit: Here are two errors I am getting on when rendering the page. One of the errors (#2) appears to be a web pack module:
Error 1
Error 2
In error 2, "Attributes" is undefined

I figured it out partially. It had to do with react-router and my routing. When developing and running it locally, it was running at the root of local host:
http://localhost
When I moved it to the IIS server, I had to create an app under the default web site, which changed the apps url to:
http://localhost/ReactJS
That caused my routing to fail and loaded a blank page. However, even though the home page loads now since fixing the routing, it is still not working as I can't navigate to the other views, but at least I have narrowed it down.

Related

Angular SSR Hot reload not working, no error, hung

I added angular universal to my project and upon saving, it compiles successfully though in the network tab I can see the request for whatever route im on gets hung on pending and the website stays loading forever in the browser. This issue is not present during CRS. Things I have tried that did not work:
I have cloned the same project elsewhere to see if it was some fat finger accident
I have not only add logic to stop DOM methods from being used, I have outright removed the use of them everywhere in the app
I added 3rd party libraries like Domino js to mock methods on Node
I started a completely blank angular project, added nothing to it other than angular universal and I get the same issue!
I will try it on another computer soon to see if it is just an issue on this machine.
What could the issue be? I don't get any errors and refreshing the page it works.
Is hot reload broken for me? missing anything?
EDIT: I have now tried it on a 2 other Windows machines and the result is the same. Perhaps this is a bug. Essentially makes Angular useless to me.
Angular Version 12.1
I was able to get it to work by upgrading my Angular to version 14, and starting a fresh project with SSR added. Frustratingly to say the least but I can finish my project and I copied back in most of my code from the project I was working on.
For what ever reason Angular 11 and 12 were giving me this issue on multiple machines on fresh angular projects. It never gave me any errors to show. I will report back if any time during the rest of the porting of code if the issue persists.
I had the same hassle when initially integrated the Angular Universal to my project.
After a period of time I consider the according workaround:
SSR for the single page applications is useful in production for SEO, Open Graph, etc.
Angular Universal adds additional files:
main.server.ts
app.server.module.ts
Then the classic angular approaches are still possible to be used (the old app.module.ts).
Now for the local development environment I'm continue using the classic "ng serve" command and the Angular continue reloads normally on each file change.
And the SSR is compileing only for the production build.
Then if I want to debug something related to the SSR I'm deploying the production build to the test environment and calling the test urls to see the results.

Running UI5 on Node JS server

I'm trying to run my ui5 pages on Node.js server. What I've done till now is created a UI5 project with a simple index.html file calling my other ui5 views showing a text message. When I run it without node js it runs fine and shows me the message.
What I'm trying to achieve now is run this on top of my node server. So I've configured a server.js file for my node and it starts up fine. In there I'm calling up my above index.html file. it calls it fine but it gives an error inside it saying sap is undefined meaning it is not able to find my ui5 resources like sap-ui-core.js and thus the error. I'm not sure why it is not able to find it.
I've created the ui5 project using eclipse which provides me the ui5 resources under the below directory but even if I try to put the resources directory under the web content directory it is not able to find it.
After manually putting resources directory:
Below is how my index.html looks like:
Has it got something to do with the resource root that I define or please if you can suggest how can I get it working.
Awaiting your responses eagerly.
Thanks,
AW
Adding to cschuff response:
Hello, thanks for taking time to help me out. Yes my apps namespace is different and definitely not something with sap.ui. Though I've got a way around of getting it to work but still would like to get this to work as well as it is much cleaner. The way I've got it working now is by creating a seperate node project altogether and then gradually adding my UI5 pieces to it and by gods grace it is running fine now. But I'm not sure why the same concept if I apply on a UI5 project created in eclipse, it gives me sap is undefined error.
My only suggestion that you misconfigured node.js server. Try start from scratch:
mkdir app
cd app
npm install -g express-generator
express -f
npm install
node .\bin\www
Than put all of your files of your project and resource in public directory. And try to open http://localhost:3000/index.html
The /resources are delivered by the com.sap.ui5.resource.ResourceServlet (see your web.xml; web.xml and Servlets are used in the Java World e.g. by Java Application Servers or Servlet Containers like Tomcat)
The ResourceServlet listens on the url-pattern /resources/* meaning every time a request is send to an url matching this pattern the ResourceServlet (a Java class) will step in, look up the right .jar file and return the required JavaScript file from it. This won't work with a plain web server like Apache.
I don't know much about express but I guess it is not able to run Java Servlets and thus is not able to deliver your SAPUI5 resources the same way Tomcat does.
To work around this you still have some options:
Use Express to serve your application sources and load UI5 from Tomcat while developing. This might lead to cross-origin problems (since localhost:8080 and localhost:3000 are considered different origins)
<script src="http://locahost:8080/resources/sap-ui-core.js" ...
Unpack all the UI5 .jars you need and place them in YourApplication/resources/.
BR
Chris

IISNode running Node.js with multiple domains issue

I put a basic, no frills node npm-express blog site up on a azure website and the IIS load balancing or just iisnode itself seemed to cause issues running the app.js. Running outside of IIS didn't experience any issues. No websockets, just express using vash templates.
The issues I ran into are:
Using web deploy and some node_modules intermittently not deploying. npm lwip for instance would work at first then wouldn't if deploying again. Sometimes other js and vash files would not update also.
When using the site there was a plain vash templates section (the public facing side) and a login side of the site. The simple one page public facing side would intermittently create a 500 error. One out of every three request would do this. No logs generated and all logging was turned on. The error was from iisnode and not node itself.
Using visual studio 13 with all the latest updates, remote debugging simply didn't work. Basically in the dark. Oddly the logged in portion using npm-passport-local worked but that never changed domains when using. It was only the pages on the public side that this would happen. FYI, the public side had multiple domains and various sub domains pointing to the site. All entered correctly in the azure portal and would work with the intermittent 500 error. The page had links to other blogs with full urls, hence the domain would change. Which should be an issue but I suspect had something to do with it.
I ended up having to create a azure vm and install node on it myself to get the site working without the use of IIS. FYI, running the node site locally on my sand I never encountered any issues either.
Has anyone else experienced issues like this using iisnode and did you find a work around for this?
I suspect it may happen when multiple domains are used for the same instance.

Running vline-node example on IIS

I have successfully tested the vline-node example locally, but would like to push it out to a server. I have tried to install the example as an application on an IIS8 website, placing the example code under wwwroot. I have done tried this both within the root and inside a virtual directory, pointing to the views folder. I am able to login to the application from a browser on the server, although, since javascript is turned off on the server browsers for security, so functionality is missing.
However, when I try to access the site from a remote browser I am not able to login. Actually, I can see that there is something wrong with my paths, as the include files are not found.
The more I've thought about this the more confused I've become. I'd like to run this under IIS, but wonder if that makes sense. Can someone offer a clean solution for hosting the vline-node example on a Windows Server, ideally under IIS?
Since you are using the node example, you'll need to make sure that node is actually running on your IIS server. Here's a SO response that may be helpful: How to run Node.JS server for a web application?
Note that in our node example the "main" file is vline-node.js, so use that in place of the app.js that is mentioned.

DotNetNuke module development errors after upgrading to VS 2012

I have been working on building a DNN module in VS 2010 under DNN 7.0.3. My module has a few controls, a web service, and some jQuery/Ajax calls to the web service. I am working in Windows 7 with IIS 7. Everything was fine until I upgraded to VS 2012. After that, I was getting 500 errors for all the files I am loading into my control, i.e. javascript files, css files, and even images (never saw a 500 error on an image before!). I tried rolling back my project to before I loaded it into VS 2012, but that didn't help. I found this article: Setting up separate ASP.NET app with DotNetNuke
and implemented the suggestion in answer 2 (adding location... to the web config file). That fixed most of the problems, but I am still getting 500 errors for 2 HttpHandlers I built (which just spit out some javascript) and for any calls to my web service. The error I am getting now is:
Parser Error. An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
It kind of looks like it can't find the codebehind for these files. That makes some sense, since that was basically the problem it was having with all the files before I added the tag to the web.config.
I tried a clean install of DNN 7.0.6 and just installed my module from the package that was created earlier, but still the same errors. Since I haven't made any change to my code since it was last working, I am pretty sure the problem has something to do with changes the VS 2012 install made to my machine but I have no idea what. Please help!!!
Thank you :-)
Check to see if you have a VIRTUAL DIRECTORY or Application on the DesktopModules folder, or on the Module's folder in there, sometimes that happens in VS.
Also make sure there is NOT a web.config file in the MODULE folder.

Resources