使用Rhino R软件包的纱线依赖性问题

发布于 2025-01-29 14:16:21 字数 4229 浏览 2 评论 0 原文

我正在尝试新的r软件包 rhino 来自Appsilon团队来构建光泽应用程序。

在Windows10笔记本电脑上运行,我按照此教程

的输出

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

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.

这是 Rhino :: Diagnostics ( “这是从“ root/app”开始的。我的应用位于我的主目录中: “ C:/users/xxx/documents/workspace/rhino_dummy”

这些路径在呼叫中是否有可能是错误的?


幸运的是,建议的 libsass 解释器的建议替代方案适用于教程中的SASS示例。在Windows10上使用SASS的Node.js可以为将来更复杂的应用程序工作。


编辑1之后,凯特(Kat)的评论

感谢凯特(Kat)的快速反馈。我通过 YARN添加 sass YARN添加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.json 通过调用<创建的文件。代码>纱线在我的R项目文件夹中。它只有最小的内容:

# 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.

I am trying the new R package rhino from the Appsilon team to build shiny apps.

Running on a Windows10 laptop I installed the dependencies node.js and yarn as described in this tutorial.

Here is the output of 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

Running rhino::build_sass() gives me this error:

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.

I am puzzled by the paths in the call to "sass" that start with "root/app". My app is located in my home directory:
"C:/Users/XXX/Documents/workspace/rhino_dummy"

Is it possible that these paths are wrong in the call?


Luckily, the suggested alternative with the deprecated libsass interpreter works for the sass example in the tutorial. It would be nice to have node.js with sass working on Windows10 for future more complex apps.


Edit 1, after Kat's comment

Thanks Kat for the quick feedback. I added sass via yarn add sass and tried again same error:

> 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.

The warning is coming from the pckage.json file that was created by calling yarn inside my R project folder. It has only minimal content:

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

Out of curiosity, I tried to compile the javascript example, also failed with very similar error regarding folder paths:

> 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

李不 2025-02-05 14:16:21

对于Node.js函数以在Windows 10上工作,您需要启用开发人员模式在您的系统上,如我们的 how-to:在Windows上使用Rhino 文章。这对于在Windows上工作的符号链接是必需的( .rhino/node/root 文件是指向项目根的符号链接)。

执行此操作后,从项目中删除 .rhino/node 目录,或在项目的根部运行 rhino :::::: add_node(clean = true)

For Node.js functions to work on Windows 10, you'll need to enable Developer Mode on your system as mentioned in our How-to: Use Rhino on Windows article. This is necessary for symbolic links to work on Windows (and the .rhino/node/root file is a symbolic link to the root of the project).

After you do that, delete the .rhino/node directory from your project, or run rhino:::add_node(clean = TRUE) in the root of your project.

本宫微胖 2025-02-05 14:16:21

解决方案

仅在Windows上启用开发人员模式(有关更多信息,请参见Kamil Zyla的帖子)。

错误消息中的文件夹名称“ root”是一个损坏的变量。

文件夹 ... \ workspace \ rhino_dummy \ .rhino \ node \ node \ root 不存在,但是子结构确实退出:

  • app \ styles \ styles \ main.scss
  • app \ js \ index.js
  • ... \ workspace \ rhino_dummy \ .rhino \ .rhino \ node

fix step1

  • 我尝试了运气并创建了文件夹“ root” : c:\ user \ xxx \ documents \ workspace \ rhino_dummy \ .rhino \ .rhino \ node \ node \ root \ root
  • codied rhino_dummy \ app \ styles \ styles \ styles \ styles.scss
  • ​JS \ index.js
  • 运行 Rhino :: build_sass() rhino :: build_js()现在工作了!

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
Done in 0.45s.

Rhino :: build_js()

yarn run v1.22.15
warning ..\..\package.json: No license field
$ webpack
asset app.min.js 470 bytes [compared for emit] [minimized] (name: main)
runtime modules 670 bytes 3 modules
./root/app/js/index.js 113 bytes [built] [code generated]
webpack 5.69.0 compiled successfully in 846 ms
Done in 2.58s.

修复了step2

  • 将结果复制回“静态”文件夹,在其中shiny可以预期它们/Rhino
  • 复制 Rhino_dummy \ .rhino \ node \ root \ root \ app \ static \ css \ app.min.css to rhino_dummy \ app \ app \ static \ static \ css \ css \ css \ app.min.css
  • 复制 \ rhino_dummy \ .rhino \ node \ root \ root \ app \ static \ js \ js \ app.min.js to \ code> \ rhino_dummy \ app \ static \ static \ static \ js \ js \ app.min.js
  • 通过 shiny :: shinyappdir(“。”)单击
  • 教程中的按钮;-)

edit1

检查rhino

sass

js

Workaround

This answer is only a workaround, if you cannot enable developer mode on windows (see Kamil Zyla's post for more information).

It looks like the folder name "root" in the error messages is a broken variable.

The folder ...\workspace\rhino_dummy\.rhino\node\root does not exist, but the substructures do exit:

  • app\styles\main.scss
  • app\js\index.js
  • ...\workspace\rhino_dummy\.rhino\node

Fix step1

  • I tried my luck and created the folder "root": C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root
  • copied rhino_dummy\app\styles\main.scss to rhino_dummy\.rhino\node\root\app\styles\main.scss
  • copied rhino_dummy\app\js\index.js to rhino_dummy\.rhino\node\root\app\js\index.js
  • running rhino::build_sass() and rhino::build_js() now worked!

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
Done in 0.45s.

rhino::build_js()

yarn run v1.22.15
warning ..\..\package.json: No license field
$ webpack
asset app.min.js 470 bytes [compared for emit] [minimized] (name: main)
runtime modules 670 bytes 3 modules
./root/app/js/index.js 113 bytes [built] [code generated]
webpack 5.69.0 compiled successfully in 846 ms
Done in 2.58s.

Fix step2

  • copy results back to "static" folder, where they are expected by shiny/rhino
  • copy rhino_dummy\.rhino\node\root\app\static\css\app.min.css to rhino_dummy\app\static\css\app.min.css
  • copy \rhino_dummy\.rhino\node\root\app\static\js\app.min.js to \rhino_dummy\app\static\js\app.min.js
  • launch the app via shiny::shinyAppDir(".")
  • click the button from the tutorial ;-)

Edit1

Checking the github repo of rhino

SASS

  • definition of build_sass()
    calling yarn("build-sass")
  • definition of build-sass
    showing hard-coded root/app/styles/main.scss

JS

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文