Skip to content

[Feature] Provide an utility to run NPM in a specific directory, with a specific node install #37

@Lucassifoni

Description

@Lucassifoni

On systems that already have a Node install, leveraging an in-app npm install by Nodelix can raise issues as Npm will lookup PATH to find node. There was a npm flag allowing to provide a custom Node path but it has been removed.

One solution is to do runtime $PATH alteration like this :

def install_deps(project_path) do
    npm = Nodelix.VersionManager.bin_path(:npm, get_vsn())
    node_dir = Path.dirname(npm)

    System.cmd(npm, ["i"],
      cd: project_path,
      env: [{"PATH", "#{node_dir}:#{System.get_env("PATH")}"}]
    )
  end

But a more general utility would be nice to have.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions