Skip to content

Change in NODE_OPTIONS parsing behavior in Node 11 #26521

Closed
@rwjblue

Description

@rwjblue
  • 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 yarnpkg/yarn#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

Metadata

Metadata

Assignees

No one assigned

    Labels

    cliIssues and PRs related to the Node.js command line interface.confirmed-bugIssues with confirmed bugs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions