Additional comments:

In your tree, there is 'app'. In your require 'App'. I'm not sure if that
name could be used without Windows.

__dirname is not the current directory (as in pwd command line). It is the
directory of the current script.

More info:
http://stackoverflow.com/questions/8131344/what-is-the-difference-between-dirname-and-in-node-js

Notice the difference of './...' in require vs fs.readFile. In require,
'./...' is the directory of the current script. But in any filesystem
operation, it is the current user directory

Angel "Java" Lopez
@ajlopez




On Sun, Apr 20, 2014 at 9:43 PM, Alejandro Paciotti <
[email protected]> wrote:

> Thank you very much!
>
> [email protected]
>
>
> 2014-04-20 21:05 GMT-03:00 Kevin Ingwersen <[email protected]>:
>
> Have you tried to use __dirname to get the current, full path, working
>> directory? Or just use relativep aths to the file from where you do the
>> instance.
>> Am Mo. Apr. 21 2014 01:43:25 schrieb Alejandro Paciotti:
>>
>> I am structuring my node.js application with express as follows:
>>
>> myApp
>> - app
>> ---- config
>> ---- models
>> -------- users. js
>> ---- routes
>> -------- routes. js
>>
>> - node_modules
>> package.json
>> server.js
>>
>>
>> I create a variable User in the file *server.js * and work fine.
>>
>> User = require (‘./App/models/users’)
>>
>>
>> But if I write the same sentence in the file routes.js I get the
>> following error message:
>>
>> *Can not find module './App/models/users' *
>>
>>
>> How I can reference an object in a js file in a subfolder?
>>
>>
>> Thanks in advance.
>>
>>
>>
>> [email protected]
>>
>> --
>>
>>
>>
>>
>>  --
>> --
>> 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/d/optout.
>>
>
>  --
> --
> 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/d/optout.
>

-- 
-- 
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/d/optout.

Reply via email to