npm / npx

npm package executor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] NODE_PATH environment variable is ignored

repinvv opened this issue · comments

What / Why

Error message: "not found: gulp"

When

  1. setx NODE_PATH "my node_modules path"
  2. npx --no-install gulp myTask

Where

Windows, Node 12.16.1

Expected Behavior

gulp from NODE_PATH used

NODE_PATH is a legacy and deprecated way to require things. It has nothing to do with running a binary, or with your PATH, so npx should have zero interaction with it.

is there any other way to reference node_modules outside of working dir?

PS in documentation it is not marked as deprecated, https://nodejs.org/api/modules.html
and I checked that it works for running js files with node.

It's deprecated in the sense that it's considered a bad practice to use it, and that while CJS has it, ESM never will - but it will never be removed from CJS either.

I'm a bit confused; you want to run gulp, as if it was in a project directory, but not in that project directory? Why?

I have a scenario where i have separate src folder and build folder. can't create/change files in src folder. Rules of our build system. So node_modules are installed or unpacked from zip into build folder. Wanted to avoid the extra step of copying everything from src folder to build folder, instead wanted to just reference that node_modules folder.

I think that step is necessary, otherwise anything that deals with modules might need configuration.