-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
child_process.spawn produces empty string for various commands (node, npm, ncu) #843
Comments
We were bitten by this same problem, and we think that is related to this: https://forum.snapcraft.io/t/snapd-2-32-breaks-live-server-installer/4597 |
I’m closing this because there hasn’t been a response or interest in this issue (which is still happening). |
For posterity, both the following scripts produce the empty string when their commands executed in a shell return a completely different (and expected) results: const npm = require('child_process').spawnSync('npm', ['ls', '--global', '--depth=0', '--json', '--prefix=/home/phil/.npm-global'])
console.log(String(npm.stdout) === ''); The asynchronous variant never runs into either callbacks for const npm = require('child_process').spawn('npm', ['ls', '--global', '--depth=0', '--json', '--prefix=/home/phil/.npm-global'])
npm.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
npm.stderr.on('data', (data) => {
console.error(`stderr: ${data}`);
});
npm.on('close', (code) => {
console.log(`child process exited with code ${code}`);
}); |
This is still broken in the Snap distribution of Node.js. The following short program logs const npm = require('child_process').spawnSync('npm', ['ls', '--global', '--depth=0', '--json', '--prefix=/home/phil/.npm-global'])
console.log(String(npm.stdout) === ''); This issue makes the Snap distribution of Node.js unuseable for me. |
I just had the same issue with coc.vim which relies on node. When it`s installed via snap coc.vim cannot check node's version number: neoclide/coc.nvim#2870 |
We are not responsible for maintaining the Snap packages, to solve any issue or more information: |
I switched from the PPA binary (https://github.com/nodesource/distributions/blob/master/README.md#debinstall) to the snap binary (https://snapcraft.io/node). This started to break the
ncu -g
command. Originally, I opened an issue with npm-check-updates, but it doesn’t seem to be an issue on their end (for reference: raineorshine/npm-check-updates#536).Only with the snap binary do I get the following error:
The command that is executed with
child_process.spawn
isnpm ls --global --depth=0 --json
which produces the correct JSON with both the PPA and the snap binary when executed directly from the terminal.Steps to reproduce:
Create a reproduction.js file containing the following code and run
node reproduction.js
withnode
being a Node.js binary from a Snap source (reproduces with all versions fromv12
tov14
at least).To switch around the Node binary on Ubuntu:
Uninstall Node.
Install Node via Snap.
Verify that Snap’s Node is used (i.e. on my system, the binary is reported to be in
/snap/bin/node
when runningwhich node
).Run npm-check-updates with the global flag.
Remove Node via Snap.
Install Node via apt.
The text was updated successfully, but these errors were encountered: