Just checked on my Ubuntu 14.04:

[ witoldsz@svp:~ ]$ sudo su -
root@svp:~# /opt/node/bin/node --version
v4.1.1
root@svp:~# /opt/node/bin/node
> require('os').homedir()
'/root'

Seems to be working just fine.

On 7/1/16, Marco Stolle <marco.sto...@gmail.com> wrote:
> Hello,
>
> i'm testing a library where i have to run the script with sudo, thats when
> i get an error on the line
>
> var homedir =require('os').homedir()
>
> (i also get this error in a file with only this line, it's unrelated to the
>
> library)
>
> this results in
>
> testhomedir.js:1
>
> quire, module, __filename, __dirname) { var homedir =
> require('os').homedir();
>
>                                                                     ^
>
> TypeError: undefined is not a function
>
>     at Object.<anonymous> (/home/marco/test/testhomedir.js:1:91)
>
>     at Module._compile (module.js:460:26)
>
>     at Object.Module._extensions..js (module.js:478:10)
>
>     at Module.load (module.js:355:32)
>
>     at Function.Module._load (module.js:310:12)
>
>     at Function.Module.runMain (module.js:501:10)
>
>     at startup (node.js:129:16)
>
>     at node.js:814:3
>
>
>
> on mac i don't have this problem on linux i do
>
>
> any ideas?
>
> --
> 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 nodejs+unsubscr...@googlegroups.com.
> To post to this group, send email to nodejs@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nodejs/ede2e5ab-c43c-4292-966b-12451c3c7f8e%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/CAAWTntidMiW3skCJLU%2BLeMVnR1Nk0nHT-yTjNy56xtbDOdJtKw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to