Specify stdio option when invoking package manager#17
Open
dave-irvine wants to merge 1 commit intods300:masterfrom
Open
Specify stdio option when invoking package manager#17dave-irvine wants to merge 1 commit intods300:masterfrom
dave-irvine wants to merge 1 commit intods300:masterfrom
Conversation
When this option isn't specified, `yarn` errors out (`npm` does not do this).
```js
const exec = require('child_process').execSync;
exec('yarn run postinstall', {});
```
```
node test.js || echo "Exit code: $?"
child_process.js:866
throw err;
^
Error: Command failed: yarn run postinstall
at checkExecSyncError (child_process.js:790:11)
at execSync (child_process.js:863:15)
at Object.<anonymous> (/tmp/test/test.js:3:1)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
at internal/main/run_main_module.js:17:47 {
status: 1,
signal: null,
output: [ null, Buffer(0) [Uint8Array] [], Buffer(0) [Uint8Array] [] ],
pid: 12204,
stdout: Buffer(0) [Uint8Array] [],
stderr: Buffer(0) [Uint8Array] []
}
Exit code: 1
```
```js
const exec = require('child_process').execSync;
exec('yarn run postinstall', { stdio: 'ignore' });
```
```
node test.js && echo "Exit code: $?"
Exit code: 0
```
danofsteele
approved these changes
Jan 31, 2022
danofsteele
reviewed
Jan 31, 2022
danofsteele
left a comment
There was a problem hiding this comment.
Sorry, haven't had my coffee yet this morning!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When this option isn't specified,
yarnerrors out (npmdoes not do this). This error only seems to occur for some people and not all. I haven't been able to narrow down the conditions that induce the error, it suddenly started happening to me today.Sample script:
Output:
Fixed script:
Output:
Node version
Yarn version
Fixes #7