07-21-2023, 10:36 AM
Just found an unusual scenario that may be of use to someone and is sort of a red herring.
I was also getting the Cannot Find Module error but oddly everything worked perfectly in my local (Mac hosted) Node.js environment. This problem only appeared when the code was deployed on our Linux server.
Well... it turned out to be a typo that (apparently) the Mac based Node.js installation was perfectly happy to ignore.
The include looked like this:
var S3Uploader = require('./S3Uploader.class');
But the actual file was called "s3Uploader.class.js"
Notice the casing difference in the 's' vs. 'S' between the code and the filename.
So - in the odd chance that none of the other solutions here are solving your problem, triple check that you're not mis-casing the characters in your included filename! :)
and DUH!
I was also getting the Cannot Find Module error but oddly everything worked perfectly in my local (Mac hosted) Node.js environment. This problem only appeared when the code was deployed on our Linux server.
Well... it turned out to be a typo that (apparently) the Mac based Node.js installation was perfectly happy to ignore.
The include looked like this:
var S3Uploader = require('./S3Uploader.class');
But the actual file was called "s3Uploader.class.js"
Notice the casing difference in the 's' vs. 'S' between the code and the filename.
So - in the odd chance that none of the other solutions here are solving your problem, triple check that you're not mis-casing the characters in your included filename! :)
and DUH!