使用 rhino R 包的纱线依赖性问题
Problem with yarn dependency using the rhino R package
我正在尝试使用 Appsilon 团队的新 R 包 rhino 来构建闪亮的应用程序。
运行 在 Windows10 笔记本电脑上我安装了依赖项 node.js 和纱线 tutorial.
这是 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 就好了。
在 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.
解决方法
如果您无法在 windows 上启用开发人员模式(请参阅 Kamil Zyla 的 post 了解更多信息),此答案只是一种解决方法。
错误消息中的文件夹名称“root”似乎是损坏的变量。
文件夹 ...\workspace\rhino_dummy\.rhino\node\root
不存在,但子结构存在:
app\styles\main.scss
app\js\index.js
...\workspace\rhino_dummy\.rhino\node
修复步骤 1
- 我试试运气并创建了文件夹“root”:
C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root
- 已将
rhino_dummy\app\styles\main.scss
复制到 rhino_dummy\.rhino\node\root\app\styles\main.scss
- 已将
rhino_dummy\app\js\index.js
复制到 rhino_dummy\.rhino\node\root\app\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.
修复步骤 2
- 将结果复制回 shiny/rhino
期望的“静态”文件夹
- 复制
rhino_dummy\.rhino\node\root\app\static\css\app.min.css
到rhino_dummy\app\static\css\app.min.css
- 复制
\rhino_dummy\.rhino\node\root\app\static\js\app.min.js
到\rhino_dummy\app\static\js\app.min.js
- 通过
shiny::shinyAppDir(".")
启动应用程序
- 单击教程中的按钮 ;-)
编辑1
正在检查 rhino 的 github 存储库
SASS
- build_sass()的定义
呼叫
yarn("build-sass")
- build-sass的定义
显示 hard-coded
root/app/styles/main.scss
JS
- build_js()的定义
呼叫
yarn("build-js")
- "webpack" build-js 的定义也在文件路径中显示 hard-coded“root”
要在 Windows 10 上使用 Node.js 功能,您需要启用 Developer Mode on your system as mentioned in our How-to: Use Rhino on Windows 文章。这是符号 links 在 Windows 上工作所必需的(并且 .rhino/node/root
文件是项目根目录的符号 link)。
完成后,从项目中删除 .rhino/node
目录,或项目根目录中的 运行 rhino:::add_node(clean = TRUE)
。
我正在尝试使用 Appsilon 团队的新 R 包 rhino 来构建闪亮的应用程序。
运行 在 Windows10 笔记本电脑上我安装了依赖项 node.js 和纱线 tutorial.
这是 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 就好了。
在 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.
解决方法
如果您无法在 windows 上启用开发人员模式(请参阅 Kamil Zyla 的 post 了解更多信息),此答案只是一种解决方法。
错误消息中的文件夹名称“root”似乎是损坏的变量。
文件夹 ...\workspace\rhino_dummy\.rhino\node\root
不存在,但子结构存在:
app\styles\main.scss
app\js\index.js
...\workspace\rhino_dummy\.rhino\node
修复步骤 1
- 我试试运气并创建了文件夹“root”:
C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root
- 已将
rhino_dummy\app\styles\main.scss
复制到rhino_dummy\.rhino\node\root\app\styles\main.scss
- 已将
rhino_dummy\app\js\index.js
复制到rhino_dummy\.rhino\node\root\app\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.
修复步骤 2
- 将结果复制回 shiny/rhino 期望的“静态”文件夹
- 复制
rhino_dummy\.rhino\node\root\app\static\css\app.min.css
到rhino_dummy\app\static\css\app.min.css
- 复制
\rhino_dummy\.rhino\node\root\app\static\js\app.min.js
到\rhino_dummy\app\static\js\app.min.js
- 通过
shiny::shinyAppDir(".")
启动应用程序
- 单击教程中的按钮 ;-)
编辑1
正在检查 rhino 的 github 存储库
SASS
- build_sass()的定义
呼叫
yarn("build-sass")
- build-sass的定义
显示 hard-coded
root/app/styles/main.scss
JS
- build_js()的定义
呼叫
yarn("build-js")
- "webpack" build-js 的定义也在文件路径中显示 hard-coded“root”
要在 Windows 10 上使用 Node.js 功能,您需要启用 Developer Mode on your system as mentioned in our How-to: Use Rhino on Windows 文章。这是符号 links 在 Windows 上工作所必需的(并且 .rhino/node/root
文件是项目根目录的符号 link)。
完成后,从项目中删除 .rhino/node
目录,或项目根目录中的 运行 rhino:::add_node(clean = TRUE)
。