-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
TypeError: Cannot read property 'trim' of undefined #22
Comments
Are you running the latest v10 version? If not I would try upgrading to the latest first. |
Yes, I have v10.12.0 installed. |
Hmm, it must be failing at Line 36 in 45a45d8
Can you add |
I already tried that, and stdout is undefined. |
However, when I log the definition of stdout on line before it I get printed processes list: console.log(await execFile('ps', [flags, `pid,${cmd}`], {maxBuffer: TEN_MEGABYTES})); but for some reason is the: {stdout} = await execFile('ps', [flags, `pid,${cmd}`], {maxBuffer: TEN_MEGABYTES}); undefined. |
I tested with removing brackets around stdout and now it works: const stdout = await execFile('ps', [flags, `pid,${cmd}`], {maxBuffer: TEN_MEGABYTES}); |
@sindresorhus Can I make the pull request for this? Want to make my first open source contribution. Can you just test it on Windows so I can know whether the corresponding windows function should be changed as well? Looking at previous commits, I would assume yes :) |
Are you sure you're actually running the correct version? Try console logging From Node.js docs:
|
Executing const { execFile } = require('child_process');
const child = execFile('node', ['--version'], (error, stdout, stderr) => {
if (error) {
throw error;
}
console.log("version", stdout);
}); gives the same node version v10.12.0 . |
const util = require('util');
const execFile = util.promisify(require('child_process').execFile);
async function getVersion() {
const { stdout } = await execFile('node', ['--version']);
console.log(stdout);
}
getVersion(); stdout in this one is undefined. |
Definitely something weird with your Node.js version as the above example runs fine for me on v10.12.0. |
I am using this boilerplate for electron app: Could there in project settings be some defined option to use other node version? I see in travis.yml file that they specified node_js version 9, but I am not sure whether that have influence on it. |
So when you run the snippet, you run it in Electron and not pure Node.js? If so, it could be an Electron bug. |
Yes, in Electron. I put that piece of code in main function. |
@sindresorhus could the problem be that this boilerplate is using Electron 2.0.6? Electron 2.0.0 uses Node 8.6 and in Version they switch to v10.2.0. |
Could be, yes. |
@sindresorhus is there any way to check whether the process has opened (not active) window? I am also using your active-win package, but need to get list of opened windows :) |
I wanted to check this library out, but after using the example code you provided I am getting the following error:
TypeError: Cannot read property 'trim' of undefined
I have node v10 installed and using it on MacOS Mojave.
The text was updated successfully, but these errors were encountered: