2

I have my Electron app which I am packaging with electron-packager npm module. I want to execute an python application only by name from Nodejs module called child_process. When the application isn't packaged it works, but when I package it does not work. I noticed that the packaged app does not load PATH variable so it works only if I change it to absolute path to the script. But I want to make it platform independent, so it is not a solution for me.

Is there any way how can I "inject" PATH variable to the packaged application or any other solution?

2 Answers 2

3

This is probably this PATH issue.

And you can fix it with this package.

const fixPath = require('fix-path');

fixPath();

console.log(process.env.PATH);
//=> '/usr/local/bin:/usr/bin'
Sign up to request clarification or add additional context in comments.

Comments

0

Are you using spawn to spin off your child process? If so, that is launched without a shell, therefore no PATH. However, you can force it to use a shell.

const myCmd = spawn('ls', args, { shell: true });

Alternatively, you could use exec which does run with a shell. Here's an article that goes into depth on the differences.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.