The cwd has nothing to do with any language because it is part of the os but it can break your app and it's nearly impossible to fix it if you don't know that cwd != dir of main file.
"node dir/app" behaves different than "cd dir && node app". The __dirname variable fixes this problem but it only works in the main file. If you have modules that use relative paths you need to pass them the directory of the main file. It's easy to forget to prefix the paths with __dirname and it's also easy to forget to call the scripts within the same dir or with an absolute path. I know that this discussion will not get any reasonable solution but my intention is to share with you this problem. IMO this is a critical flaw in all the languages that should be fixed, but no one cares. Maybe we could do that if the --use-strict cli variable is enabled it could show a warning message like this: CWDError: If the main file is executed with a relative path, it should be started from the same directory. The process has been started this way: node dir/app.js Better alternatives: cd dir && node app.js node <absolute_path>/dir/app.js What do you think? This warning (if enabled) won't break any old codes, even if __dirname is being used. -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
