node.js - node不识别r exe启动路径
问题描述
我正在尝试在节点中使用 r-integration 包,
在我的环境“PATH”变量中,我有 r 的路径
C:\apps\R-3.6.2\bin\x64;
由于 IT 原因,我无法将 r 安装到程序文件中。
当我在节点中运行它时
const R = require('r-integration');
let result = R.executeRCommand("max(1,2,3)");
console.log(result);
我收到一个错误
未捕获的错误:ENOENT:没有这样的文件或目录,lstat 'C:\Program Files\R'
有没有办法让它与当前的 r 路径一起工作?
谢谢
解决方案
R
不幸的是,除了进入程序文件目录之外,您似乎无能为力。如果你看一下source-code,路径是硬编码的:
if (fs.lstatSync("C:\\Program Files\\R").isDirectory()){
// Rscript is installed, let's find the path (verison problems)
installationDir = "C:\\Program Files\\R";
您当然可以分叉存储库并更改代码以允许自定义路径甚至更好 - 创建拉取请求以使目录可配置。
推荐阅读
- javascript - 有什么方法可以使用 JavaScript 访问 HTML 文本区域中的特定文本行?
- python - 如何将默认的python3设置为python3.7?
- python - 如何以正确的顺序执行命令
- git - 如何在mac os中允许访问git/config?
- arrays - 是否可以创建一个可以在工作簿中搜索多个工作表以进行多个查询的脚本?
- selenium - 如何获取有关失败的硒测试的有用信息
- c++ - 在 Windows 上编译为 C++20
- algorithm - 证明一个索引不属于 Optimal Sub Interval Sum
- python - 尝试创建一段代码,其作用类似于打开或关闭的开关
- docker-desktop - 为 Windows 10 安装 Docker 桌面时出错