How can I use node-sendmail to send emails? This package crashed the server - node.js

I'm using the node-Sendmail npm package in my express JS app, which is like the MVC structure. I have some weird errors, like
node_modules\sendmail\sendmail.js:291
if (mail.to) {
^
TypeError: Cannot read properties of undefined (reading 'to')
Please see the image above. I tried to send the email when the login route was requested, but it sent the email after the server crashed, and this error showed. I checked their official GitHub and asked a question, but no one replied. Have you ever used a node-Sendmail package?
I checked to see if there were any errors in the node module package and code, and here is a screenshot.
I called the Sendmail with import module :

You're calling sendmail with no configuration on line 47, that is throwing your error

Related

Problems Deploying Node App With Render.com

I would like to post a simple stripe integration on render. I apologize in advance for my ignorance on the topic but, since I'm more front-end oriented, it's the first time I've attempted to do such a thing so I would like to ask you
if the repository https://github.com/Luca-Liseros-Ferrari/stripe-example.git is ready to be published, if there is some error that can cause the deploy to fail or if some preliminary operation is required (in the server folder I also have an .env file with the stripe keys and I specified STATIC_DIR = "../client/")
In render.com after clicking on "new" - "web service" and connecting the github repository and considering that from the terminal I start the server.js with the following commands:
cd server
node server.js
how should I fill in the "root directory", "build command" and "start command" fields since it's still not clear to me? Is the root directory the folder that contains the server.js file inside? In my case it would be for example "folderName/server" or simply "server"?
I tried to upload the repository to render but i get the following error message
Failed - Exited with status 1 while running your code.
It also tells me "error cannot find module express"
then I reinstalled express in server folder with npm install express and verified it was already installed. I therefore believe that there is a path error in the phase in which I create the web service.
error snippet
I hope I have provided enough data and I thank anyone who is willing to give me a hand in advance
I solved the problem. I had to specify in render.com in advanced the key - value pairs of my .env file
I noticed it thanks to the Cyclic app which, after loading the repository, warned me that if the app doesn't work it could be because of that
I hope it will help someone

Website on nodejs and mongodb typeerror cannot read properties of undefined (reading 'date') after moving to new server

I hope I'm in the right place.
We have a problem with our website. We only got files and a database from the previous admin. I uploaded them to the server and the site is partially working.The problem arises when we click one of the links to articles on the site. The place where the article should be placed is empty. The console in chrome says:
TypeError: Cannot read properties of undefined (reading 'date')
at Cn.eval (eval at Qa (vue.js:6:92206), <anonymous>:3:386)
at e._render (vue.js:6:35554)
at Cn.r (vue.js:6:68565)
at pn.get (vue.js:6:26867)
at pn.run (vue.js:6:27751)
at ln (vue.js:6:25859)
at Array.<anonymous> (vue.js:6:12476)
at We (vue.js:6:11877)
and a warning:
"DevTools failed to load source map: Could not load content for https://example.com/js/axios.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE"
I read about it on stack and other pages and it seams that the variables aren't defined.
It was working on the previous server. :(
As I understand it, when I copied the files and the database and installed all the dependencies it should work? Or is there anything that I'm missing?
I think that connection with database works, other parts of the website are working and some of the data for the website is working fine.
It seams like there is something missing, but I have no idea what.
Can it be that because of the missing axios.map file the js can't define some of the variables on the website?
What could have caused it during the transfer? Some files missing? collection error in mongodb?
I'm struggling for over a week now, and I ran out of ideas for the moment...
Is there any way I can debug it?
I'm not a js programmer but a simple admin and I'm getting kind of confused. Has anyone had such a problem?
If anyone needs any more info please let me know.
What I did:
installed nodejs via nvm install 12.18.4 //it's the version on which it was working earlier, on previous server
installed mongo and imported collections to the database in json format
installed and configured nginx to handle the request foe the website
deleted the modules folder and npm install'ed them again

Debug compilation errors errors using Angular Universal in Angular 8 Application

A Brief Backstory
I have been implementing several upgrades to an Angular 8 application such as server-side rendering, and Google Analytics. As most developers do, I would code then test then move on to the next task. Typically I use ng serve to run the application as I am developing.
With Server-side rendering, to test speed, lazy-loaded images, etc, you need to use a node express server running on a generated JS file. After building, etc, I use Node prerender (my js file is prerender.js) to see what the application will look like prerendering on the server.
When I run this command, I should not get any errors, and I know my prender file will start a local server on port 4000.
The Problem
I get errors when running a node express server that I do not get when running with ng serve I recently got an error that said:
Unhandled Promise rejection: Cannot read property 'subscribe' of undefined ; Zone: <root> ; Task: Promise.then ; Value: TypeError: Cannot read property 'subscribe' of undefined
at new ApplicationRef (C:\4towerdevelopment\dist-stage\server\main.js:45910:37)
at _createClass (C:\4towerdevelopment\dist-stage\server\main.js:37184:20)
at _createProviderInstance (C:\4towerdevelopment\dist-stage\server\main.js:37138:26)
at initNgModule (C:\4towerdevelopment\dist-stage\server\main.js:37044:32)
at new NgModuleRef_ (C:\4towerdevelopment\dist-stage\server\main.js:38176:9)
at Object.createNgModuleRef (C:\4towerdevelopment\dist-stage\server\main.js:38159:12)
at NgModuleFactory_.create (C:\4towerdevelopment\dist-stage\server\main.js:50821:25)
at C:\4towerdevelopment\dist-stage\prerender.js:29175:43
at ZoneDelegate.invoke (C:\4towerdevelopment\dist-stage\prerender.js:481:26)
at Object.onInvoke (C:\4towerdevelopment\dist-stage\prerender.js:28683:33) TypeError: Cannot read property 'subscribe' of undefined
at new ApplicationRef (C:\4towerdevelopment\dist-stage\server\main.js:45910:37)
at _createClass (C:\4towerdevelopment\dist-stage\server\main.js:37184:20)
at _createProviderInstance (C:\4towerdevelopment\dist-stage\server\main.js:37138:26)
at initNgModule (C:\4towerdevelopment\dist-stage\server\main.js:37044:32)
at new NgModuleRef_ (C:\4towerdevelopment\dist-stage\server\main.js:38176:9)
at Object.createNgModuleRef (C:\4towerdevelopment\dist-stage\server\main.js:38159:12)
at NgModuleFactory_.create (C:\4towerdevelopment\dist-stage\server\main.js:50821:25)
at C:\4towerdevelopment\dist-stage\prerender.js:29175:43
at ZoneDelegate.invoke (C:\4towerdevelopment\dist-stage\prerender.js:481:26)
at Object.onInvoke (C:\4towerdevelopment\dist-stage\prerender.js:28683:33)
The closest this gets me to figuring what actually is causing the problem is letting me know that a provider somewhere is causing this error. Looks like something should be an observable rather than a subscription. Beyond that, I guess I just start looking through my providers. My question is:
How can I force Angular to possibly throw this error when developing using ng serve?
If I can't, is there a better way to debug this current error besides combing through each provider? Or at least a way to tell what service is causing the issue?
Thank you.
UPDATE: Basic repo with problem here. I made a new angular project, made sure dependencies were up to date, installed ngUniversal per this post, and received this same Unhandled promise message when running node prerender
Verbatim I went to to the Angular cli website, made a new project (default Angular version installed was 8.3), installed Angular Universal, and tried to build. Same error message as above.
This looks like it was ApplicationRef that triggered the error, and that class is provided internally by the Angular core.
It could be failing in the constructor of the class, and there are a few calls to subscribe on Zone observables. I don't think you're going to find anything in your source code that directly relates to this error. It looks like a build configuration problem.
https://github.com/angular/angular/blob/bb52fb798c8578c461d21aee2b7623232184a5d3/packages/core/src/application_ref.ts#L562
I do not know what could possibly produce this problem, but I would start a new project with SSR and compare the differences to your current project.
Eventually, I dropped the angular 6 approach using pre-render, and went with the latest universal package. There seems to be no problem building using npm run build:ssr and serving dist/server.js in an express server. I am not sure what the problem was with the pre-render approach, but it seems to be outdated anyways. #Reactgular thanks for the feedback.

Error in setting up swagger in expressjs project

I have followed [this][1] link to add swagger to my existing project. I encountered the following error while setting up swagger. Any leads will be highly appreciated.
:xxx\node_modules\swagger-node-express\Common\node\
swagger.js:84
self.appHandler.get(self.resourcePath.replace(self.formatString, self.jsonSuff
ix), resourceListing);
^TypeError: Cannot read property 'get' of null
[1]: https://github.com/shawngong/Swagger-Node-Express-For-Existing-APIs
This error is popping out because of -
var applicationUrl = 'http://localhost:9000'; //application runs properly on this url
swagger.configure(applicationUrl, '1.0.0');//error here
Looking at the line of code in question node-swagger-express it seems as if you need to call :
swagger.setAppHandler(app);
Before the configure call.
I specifically see the maintainer of the project you are using (https://github.com/shawngong/Swagger-Node-Express-For-Existing-APIs) has a commit message related to setAppHandler in his last commit. Perhaps there is now an issue related to it.

How to debug a '4005 Path Not Found' error?

I am trying to integrate Pusher with my web application that uses backbone.js. I'm following the Pusher with Backbone guide in the Pusher docs.
So I'm seeing this error pop up in the web console on application start up
Pusher : Error : {"type":"PusherError","data":{"code":4005,"message":"Path not found"}}
What is this 'path' that cannot be found? I found nothing in the Pusher docs.
A 4005 error generally means that the WebSocket URL you are using doesn't identify an application to connect to.
In terms of usage of the Pusher JavaScript library this means you've likely supplied an empty string as the app_key to the Pusher constructor.
var pusher = new Pusher('');
You can see this in action here:
http://jsbin.com/evulaj/1/edit
Open the JavaScript console to see the error. You can also check the app_key value set by checking pusher.key.
Note: I appreciate this error is a bit cryptic. I'll see if we can remedy this
in my case, wsHost: process.env.MIX_PUSHER_WS_HOST was giving an empty value, and fixed it by changing .env file.
PUSHER_WS_HOST=my.host.com
MIX_PUSHER_WS_HOST="${PUSHER_WS_HOST}"
or you can do:
wsHost: window.location.hostname

Resources