我尝试的是:
exec( "export PATH=/Users/shubhamkumar/flutter/bin:$PATH",
(err, stdout, stderr) => {
if (err) {
console.log(err); // node couldn't execute the command
return;
}
// the *entire* stdout and stderr (buffered)
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
});
但它没有将路径设置为临时路径。 当我试图执行此
时 exec("flutter doctor", (err, stdout, stderr) => {
if (err) {
console.log(err); // node couldn't execute the command
return;
}
// the *entire* stdout and stderr (buffered)
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
});
它说'命令未找到:颤动'
答案 0 :(得分:0)
您可以通过设置process.env
对象临时设置env变量。尝试以下(未经测试):
process.env.PATH = '/Users/shubhamkumar/flutter/bin:' + process.env.PATH
exec("flutter doctor", (err, stdout, stderr) => {
if (err) {
console.log(err); // node couldn't execute the command
return;
}
// the *entire* stdout and stderr (buffered)
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
});