I have developed a node.js program using the express framework on my computer, where it runs fine with no complaints.
However, when I run the program on my SUSE Studio appliance, where it is intended to live, I receive an error at any file interaction.
Error: ENOENT, stat './path/to/file'
I have checked that the file permissions are correct, which they are. My computer and my appliance are running different versions of node, if this matters.
Any thoughts?
Paths specified with a
.are relative to the current working directory, not relative to the script file. So the file might be found if you runnode app.jsbut not if you runnode folder/app.js. The only exception to this isrequire('./file')and that is only possible becauserequireexists per-module and thus knows what module it is being called from.To make a path relative to the script, you must use the
__dirnamevariable.or potentially