I've always used './' without any problems, which is relative.  The dot 
slash just references the current directory.  I would think that this way 
(the dot slash) would be the proper way to include files.


On Monday, April 13, 2015 at 9:48:20 AM UTC-4, Alexander Myshov wrote:
>
> work with the code which isn't include an absolute path in a require 
> statement. For example i have this structure:
>
> project|+-helpers|   ||   +-helper1.js|   +-helper2.js|   +- ...|+-modules
>     |
>     +-moduleDirectory1
>     |    |
>     |    +-module11.js
>     |    +-module12.js
>     |
>     +-moduleDirectory2
>          |
>          +-module21.js
>          +-module22.js
>
> And modules which use helpers just include them this way:
>
> // for example module11.jsvar helper1 = require('helpers/helper1');var 
> helper2 = require('helpers/helper2');
> helper1.someFunction();
>
> Application work just fine, but the development tools like ternjs, and 
> node plugin for vim don't recognize this statement properly. When I replace 
> it with something like this: require('../../helpers/helper2') plugins 
> start work.
>
> I've searched a while but didn't find any information about "requiring" 
> regular files without absolute path. Only about node_modules in official 
> docs <https://nodejs.org/api/modules.html>:
>
> >> Without a leading '/' or './' to indicate a file, the module is either 
> a "core module" or is loaded from a node_modules folder.
>
> Is it a good idea to use including a regular files without an absolute 
> paths?
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/2b10efbd-c3f5-4d70-aa8b-8879b348e605%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to