I'm working on trying to learn node.js, and am playing around with the imap and mailparser sample code found here. I installed both imap and mailparser according to the instructions in the readme documents found on their respective github pages, and everything installed fine without any errors. When attempting to run the sample code, I get the following error:
Error: Cannot find module 'iconv'
After installing the modules, my project directory structure looks like this:
~/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 of the googling that I've done for this problem, I've noticed that this "Cannot find module" error seems to be a fairly common one, but I've been able to see a consistent solution to the problem.
Is the problem here the nested node_modules
directory in the mailparser
folder? Should the contents of that folder actually be in the node_modules
folder at the root of the project? Is this a project setup issue, or an environmental issue?
Environment: Ubuntu 12.04, Node.js v0.6.17, npm v1.1.21.