Node: Change in NODE_OPTIONS parsing behavior in Node 11

Created on 8 Mar 2019  路  13Comments  路  Source: nodejs/node

  • Version: v11.9.0
  • Platform: Darwin
  • Subsystem:

If NODE_OPTIONS starts with a leading space the --require option does not function (possibly other flags but I've only tested --require).

Specifically:

NODE_OPTIONS="--require ./some-file.js" node ./other-file.js

^ will properly require ./some-file.js prior to executing ./other-file.js

Whereas:

NODE_OPTIONS=" --require ./some-file.js" node ./other-file.js

^^ will not require ./some-file.js at all

Steps to reproduce:

mkdir test-node-options
cd test-node-options
echo "console.log('first!')" > first.js
echo "console.log('second!')" > second.js

Then compare the output of these two commands:

# "broken"
NODE_OPTIONS=" --require ./first.js" node ./second.js

# "working"
NODE_OPTIONS="--require ./first.js" node ./second.js

I stumbled across this while attempting to use Yarn's PnP system on Node 11 (see https://github.com/yarnpkg/yarn/issues/7092 for the original report there). Yarn 1.13.0 adds --require ${PATH_TO_PNP_FILE} to NODE_OPTIONS which causes this issue.

/cc @arcanis @turbo87 @stefanpenner

cli confirmed-bug

Most helpful comment

@stefanpenner it seems this shipped with Node.js 11.12.0. I'm going to close this. Please comment back if needed.

All 13 comments

Wow 馃槷 The most obvious suspect would be 8ec3c350f54933d9237c63dd17a9a24472fce591

Probably a good time to put #24065 back on the table as well

@arcanis Do you want to continue work on your PR and fix this along with it? Otherwise we can do a new PR for this specific problem?

I'll give it a look this evening (I might have to revert part of 8ec3c35 since it wouldn't make sense to use the same SplitString anymore?) - if no progress by the end of the week feel free to fix it separately 馃檪

@arcanis I think both consumers of SplitString() would like to skip empty items (which I assume is the issue here), so I think it鈥檚 okay to modify the common code. But yeah, reverting it should also be fine.

@rwjblue thanks for debugging this one!

Can we make SplitString() to trim white spaces?

maybe we should ignore white spaces like this on SplitString()

    if (item.empty()) continue;

I've rebased, updated, and fixed this issue in #24065

@Himself65 / @arcanis is the plan to ship this as part of an upcoming [email protected] release?

@Himself65 / @arcanis is the plan to ship this as part of an upcoming [email protected] release?

i don鈥檛 know :(

you can ask the Node Team Members about it.

cc @addaleax ^

@stefanpenner it seems this shipped with Node.js 11.12.0. I'm going to close this. Please comment back if needed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jmichae3 picture jmichae3  路  3Comments

mcollina picture mcollina  路  3Comments

danielstaleiny picture danielstaleiny  路  3Comments

srl295 picture srl295  路  3Comments

willnwhite picture willnwhite  路  3Comments