Skip to content

stderr redirection breaks require #11257

@michaelglass

Description

@michaelglass
  • Version: 7.5.0
  • Platform: Darwin Kernel Version 16.5.0 (mac os sierra)

related workaround: rtfeldman/node-test-runner#106, rtfeldman/node-test-runner@959fda0

We noticed that when redirecting stderr AND receiving input script via pipe, require doesn't work with packages in package.json.

Minimal test case: (given a package.json that includes ajv).

echo "require('ajv')" | node &> js.out || cat js.out

expected output: nothing, it's just a require

actual output:

fs.js:56
    assertEncoding(options.encoding);
    ^

TypeError: assertEncoding is not a function
    at getOptions (fs.js:56:5)
    at Object.realpathSync (fs.js:1468:13)
    at toRealPath (module.js:130:13)
    at tryFile (module.js:126:22)
    at tryPackage (module.js:107:10)
    at Function.Module._findPath (module.js:183:20)
    at Function.Module._resolveFilename (module.js:468:25)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)

also tested on another Ubuntu 14.04 server. Was not a problem using node 6.9.5

Metadata

Metadata

Assignees

Labels

confirmed-bugIssues with confirmed bugs.fsIssues and PRs related to the fs subsystem / file system.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions