xoid
xoid

Reputation: 1134

process.env TypeError: Cannot read property 'PATH' of undefined

Why do I get "Cannot read property 'PATH' of undefined" in code like this

console.log(process.env.PATH)

I expect to get UNIX envirement variable PATH (PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)

but my node.js "process.env" variable is undefined

Upvotes: 0

Views: 1632

Answers (1)

xoid
xoid

Reputation: 1134

The problem is I used function "process" further in some code in the same scope:

var path = process.env.PATH
// a lot of code
// .. more code
function process(something) 
{ 
     // process something
} 

Do not do this!

Upvotes: 6

Related Questions