Cannot find module 'nodemailer'
Asked Answered
R

5

10

I'm using the Zapier Code application, I need to send an email receiving trello parameters, I'm using a javascript encoding along with node.js, but when I try to find the nodemailer module I always get the error that it can not be found.

The error always points to this line of code:

var nodemailer = require ('nodemailer');
Ralli answered 15/5, 2017 at 14:32 Comment(1)
Did you try something like this? If you need more control on the data, you can put some Javascript in between.Hagberry
I
21

It sounds like you have not installed nodemailer from npm. Navigate to your project folder through a command line terminal and install nodemailer with the below command. If you have a package.json file (and you probably should), you can use the --save flag to record the version you install with your app.

npm install nodemailer --save

Note that nodemailer requires Node.js version 6+ to work correctly. Check your Node.js version with node --version on Windows or OSX and nodejs --version on linux.

Since you're asking this question, you will probably benefit from reading about npm here: https://www.npmjs.com/get-npm

Your package.json file should have the following dependency. You may have to adjust version number to match Zapier requirements.

{
  "dependencies": {
    "nodemailer": "^4.0.1"
  }
}

Upon browsing the Zapier website, it looks like they offer tech support even for free customers. You may consider contacting them directly if this does not resolve your issue.

Iguanodon answered 15/5, 2017 at 14:35 Comment(5)
Hello friend thank you very much for your attention I am using the Zapier Code application and in the documentation it informs that it supports Node 4.3.2, do you think I can accomplish my action with these features?Ralli
Are you able to determine the version of Nodemailer that you are using? Is there a record of the version anywhere in your application? I know the Nodemailer website says Nodemailer version 4+ requires Node.js version 6+ nodemailer.com/aboutIguanodon
I can tell the version of node.js that is supported through the application documentation that is available at this link: zapier.com/help/code (By searching for "node" on the page, the first result already shows the version). Does this help in any way?Ralli
Everywhere I look in the Nodemailer documentation says Node.js 6+ is wanted for version 3 and up. Version 2 of nodemailer is no longer supported. You could try setting the package.json dependency to version 2 and see if you have any success.Iguanodon
You are helping me after 3 hours of searching. Thanks.Claudieclaudina
G
1

First ensure you call npm install nodemailer --save at project root.

Then replace

Var nodemailer = require ('nodemailer');

with

var nodemailer = require('nodemailer');

Gaul answered 15/5, 2017 at 14:36 Comment(0)
H
1

You can't import npm modules in "Zaps": Requiring or Using External Libraries

Hagberry answered 19/5, 2017 at 18:26 Comment(0)
C
0

Use this :

npm install nodemailer

And your var nodemailer = require ('nodemailer') will work.


https://docs.npmjs.com/getting-started/installing-npm-packages-locally

https://www.npmjs.com/package/nodemailer

Cupcake answered 15/5, 2017 at 14:37 Comment(2)
yarn add nodemailer. Also you forgot 'er' at the end of nodemailShepperd
Thanks for the reply, my friend. I've added this line of code, but now the Zapier Code application tells me: SyntaxError: Unexpected identifierRalli
A
0

Make sure you have a dependency in package.json inside functions Make sure you have a dependency in package.json inside functions

Abessive answered 27/3, 2022 at 21:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.