gpt4 book ai didi

r - 使用 rhino R 包的 yarn 依赖性问题

转载 作者:行者123 更新时间:2023-12-05 04:29:36 26 4
gpt4 key购买 nike

我正在尝试新的 R 包 rhino来自 Appsilon 团队,以构建 Shiny 的应用程序。

在 Windows10 笔记本电脑上运行,我按照 tutorial 中的描述安装了依赖项 node.js 和 yarn .

这是 rhino::diagnostics() 的输出:

Windows 10 x64 build 19042
R version 4.1.0 (2021-05-18)
rhino: 1.0.0
node: v16.15.0
yarn: 1.22.15

运行 rhino::build_sass() 给我这个错误:

yarn run v1.22.15
$ sass --no-source-map --style=compressed root/app/styles/main.scss:root/app/static/css/app.min.css
Error reading root\app\styles\main.scss: no such file or directory.
error Command failed with exit code 66.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error:
! System command 'yarn' exited with status 66.
i If you can't use Node.js and yarn, try using sass: 'r' configuration.
Run `rlang::last_error()` to see where the error occurred.

我对以“root/app”开头的“sass”调用路径感到困惑。我的应用程序位于我的主目录中:"C:/Users/XXX/Documents/workspace/rhino_dummy"

有没有可能是调用的这些路径有误?


幸运的是,建议使用已弃用的 libsass 解释器的替代方案适用于教程中的 sass 示例。如果 node.js 和 sass 在 Windows10 上运行以用于 future 更复杂的应用程序,那就太好了。


在 Kat 发表评论后编辑 1

感谢 Kat 的快速反馈。我通过 yarn add sass 添加了 sass 并再次尝试同样的错误:

> rhino::build_sass()
yarn run v1.22.15
warning ..\..\package.json: No license field
$ sass --no-source-map --style=compressed root/app/styles/main.scss:root/app/static/css/app.min.css
Error reading root\app\styles\main.scss: no such file or directory.
error Command failed with exit code 66.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error:
! System command 'yarn' exited with status 66.
i If you can't use Node.js and yarn, try using sass: 'r' configuration.
Run `rlang::last_error()` to see where the error occurred.

警告来自 pckage.json 文件,该文件是通过在我的 R 项目文件夹中调用 yarn 创建的。它只有最少的内容:

# package.json
{
"dependencies": {
"sass": "^1.51.0"
}
}

出于好奇,我尝试编译 javascript 示例,但也因文件夹路径方面的非常相似的错误而失败:

> rhino::build_js()
yarn run v1.22.15
warning ..\..\package.json: No license field
$ webpack
assets by status 0 bytes [cached] 1 asset

ERROR in main
Module not found: Error: Can't resolve 'C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root\app\js\index.js' in 'C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node'
resolve 'C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root\app\js\index.js' in 'C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node'
using description file: C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration using description file: C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\package.json (relative path: ./root/app/js/index.js)
no extension
Field 'browser' doesn't contain a valid alias configuration
C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root\app\js\index.js doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root\app\js\index.js.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root\app\js\index.js.json doesn't exist
.wasm
Field 'browser' doesn't contain a valid alias configuration
C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root\app\js\index.js.wasm doesn't exist
as directory
C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root\app\js\index.js doesn't exist

webpack 5.69.0 compiled with 1 error in 162 ms
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error in `system_yarn()`:
! System command 'yarn' exited with status 1.
Run `rlang::last_error()` to see where the error occurred.

最佳答案

要使 Node.js 函数在 Windows 10 上运行,您需要启用 Developer Mode在您的系统上,如我们的 How-to: Use Rhino on Windows 中所述文章。这是符号链接(symbolic link)在 Windows 上工作所必需的(.rhino/node/root 文件是指向项目根目录的符号链接(symbolic link))。

在你这样做之后,从你的项目中删除 .rhino/node 目录,或者在你的项目的根目录中运行 rhino::add_node(clean = TRUE)项目。

关于r - 使用 rhino R 包的 yarn 依赖性问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72273192/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com