Skip to content

process.env.PATH not set correctly on windows #91

@janni83

Description

@janni83

Hi guys,

I just played a bit with the "which" module from npm which uses the process.env.PATH variable to find a executable file, but it couldn't find cmd.exe or java.exe on my system because process.env.PATH was empty. After I had a deeper look into this I found found that the PATH variable on my windows system is called "Path" and not "PATH".

var which = require("which");

// does not find java
which("java", function(err, result) {
  if (err) {
    return console.log(err);
  }
  console.log(result);
});

process.env.PATH = process.env.Path;

// now it works
which("java", function(err, result) {
  if (err) {
    return console.log(err);
  }
  console.log(result);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions