Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Env Var NODE_REQUIRE #11853

Closed
jchip opened this issue Mar 15, 2017 · 7 comments
Closed

Feature request: Env Var NODE_REQUIRE #11853

jchip opened this issue Mar 15, 2017 · 7 comments
Labels
feature request Issues that request new features to be added to Node.js. module Issues and PRs related to the module subsystem.

Comments

@jchip
Copy link

jchip commented Mar 15, 2017

  • Version: 4.x.x, 6.x.x, 7.x.x
  • Platform: All
  • Subsystem:

I am requesting for something that's basically the command line option -r but through an environment variable NODE_REQUIRE. The reason is that the -r option is not persistent. If some other app invokes node, then the -r is not applied. The environment variable NODE_REQUIRE should always be checked when node starts up.

When the env var exist and -r is also specified, I think both should be required.

Thanks.

@jasnell jasnell added the feature request Issues that request new features to be added to Node.js. label Mar 15, 2017
@mscdex mscdex added the module Issues and PRs related to the module subsystem. label Mar 15, 2017
@cjihrig
Copy link
Contributor

cjihrig commented Mar 16, 2017

Seems like preloading multiple modules via environment variable might be a bit of a pain if the list delimiter was part of a file path to a local module. For example, node -r ./,.js is valid, but would be a pain to parse if the delimiter was a comma.

@jchip
Copy link
Author

jchip commented Mar 16, 2017

I think that NODE_REQUIRE would only refer to a single module. Does -r let you specify multiple with a delimiter? My impression from the doc is that you can repeat -r to load multiple, but I think that's really not necessary for the env option. Or possibly NODE_REQUIRE_nnn?

@cjihrig
Copy link
Contributor

cjihrig commented Mar 16, 2017

You can preload multiple modules by passing multiple -rs from the command line. People would probably expect to be able to do something similar with an environment variable.

@jchip
Copy link
Author

jchip commented Mar 16, 2017

ok. I'd go with checking NODE_REQUIRE, and then NODE_REQUIRE_1, NODE_REQUIRE_2, etc.

@jchip
Copy link
Author

jchip commented Mar 16, 2017

or go with the convention use for NODE_PATH?

@cjihrig
Copy link
Contributor

cjihrig commented Mar 16, 2017

Yea, I suppose using : or ; depending on the OS could work.

jchip added a commit to jchip/node that referenced this issue Mar 17, 2017
Adds a new feature that checks the environment variable NODE_REQUIRE
that should be a : (or ; on windows) delimited string of modules to
preload, the same as those that can be specified by the -r command
line option. 

Implements: nodejs#11853
jchip added a commit to jchip/node that referenced this issue Mar 18, 2017
Adds a new feature that checks the environment variable NODE_PRELOAD
that should be a : (or ; on windows) delimited string of modules inside
the global node_modules dir to preload, the same as those that can be
specified by the -r command line option except this is limited to
global node_modules. 

Each module can be the absolute path of the module or just the name
of the module under the global node_modules dir.

Implements: nodejs#11853
jchip added a commit to jchip/node that referenced this issue Mar 18, 2017
Adds a new feature that checks .node_preloadrc for a list of modules
to preload.  One module per line and each one can be the absolute
path or just the name of the module.

Two locations will be check for the rc file: HOMEDIR or CWD.
The one in HOMEDIR must specify modules under the global node_modules
dir only, and the one in CWD must specify modules under the dir
CWD/node_modules only.

This is smilar to what can be specified by the -r command line
option except the modules are limited to the global or local
node_modules only.

This feature must be opted-in with setting the env var
NODE_PRELOADRC_ENABLE to a non-falsy value.

Implements: nodejs#11853
@jchip
Copy link
Author

jchip commented Mar 25, 2017

closing, conversation moved to #11997

@jchip jchip closed this as completed Mar 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. module Issues and PRs related to the module subsystem.
Projects
None yet
Development

No branches or pull requests

4 participants