Node.js mailparser module error: cannot find module 'iconv'

I am working on finding node.js and I am playing with the imap and mailparser code sample found here . I installed imap and mailparser according to the instructions in the readme docs found on their respective github pages, and everything installed perfectly without any errors. When I try to run the sample code, I get the following error:

Error: Cannot find module 'iconv'

After installing the modules, the structure of my project is as follows:

 ~/ProjectDir | -- node_modules | | | -- imap | | | | | -- LICENSE | | -- README.md | | -- imap.js | | -- package.json | -- mailparser | | | | | -- lib | | | | | | | -- datetime.js | | | -- mailparser.js | | | -- streams.js | | -- node_modules | | | | | | | -- iconv | | | | ... | | | -- mimelib | | | | ... | | -- test | | | ... | | -- LICENSE | | -- README.md | | -- package.json | | ... | -- config.json | -- mailFether.js | -- readme.md 

So, based on some errors that I made for this problem, I noticed that this โ€œCannot find the moduleโ€ error seems to be quite common, but I was able to see a consistent solution to the problem.

Is the problem here a nested node_modules directory in the mailparser folder? Should the contents of this folder be in the node_modules folder in the root of the project? Is this a project installation problem or an environmental problem?

+4
source share
1 answer

Just try installing the iconv module: npm install iconv - and look at the output of this command, iirc iconv will build a binary file, it may fail under circumstances, then we need to find out why this fails - but in this case we could only help if you provide the output of the install command.

Is the problem here a nested node_modules directory in the mailparser folder?

No, that's fine, so npm works. All module dependencies are stored in the node_module subfolder.

+2
source

Source: https://habr.com/ru/post/1413182/


All Articles