【问题标题】:expo install react-native-svg "error Running this command will add the dependency to the workspace root rather than the workspace itself..."expo install react-native-svg“错误运行此命令会将依赖项添加到工作区根目录而不是工作区本身......”
【发布时间】:2021-10-14 15:23:40
【问题描述】:

我正在使用 Expo CLI。我想在 React Native 中使用 SVG。所以,我按照https://github.com/react-native-svg/react-native-svg 的说明进行操作。但是当我安装expo install react-native-svg 时收到以下错误:

expo install react-native-svg 
    > yarn add react-native-svg
    yarn add v1.22.11
    info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
    error Running this command will add the dependency to the workspace root rather than the workspace itself, which might not be what you want - if you really meant it, make it explicit by running this command again with the -W flag (or --ignore-workspace-root-check).
    yarnpkg exited with non-zero code: 1
    Error: yarnpkg exited with non-zero code: 1
        at ChildProcess.completionListener (C:\Users\85620\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\spawn-async\src\spawnAsync.ts:65:13)
        at Object.onceWrapper (events.js:482:26)
        at ChildProcess.emit (events.js:375:28)
        at ChildProcess.cp.emit (C:\Users\85620\AppData\Roaming\npm\node_modules\expo-cli\node_modules\cross-spawn\lib\enoent.js:34:29)
        at maybeClose (internal/child_process.js:1055:16)
        at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
        ...
        at Object.spawnAsync [as default] (C:\Users\85620\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\spawn-async\src\spawnAsync.ts:26:19)
        at YarnPackageManager._runAsync (C:\Users\85620\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\package-manager\src\NodePackageManagers.ts:309:31)
        at YarnPackageManager.addAsync (C:\Users\85620\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\package-manager\src\NodePackageManagers.ts:258:16)
        at actionAsync (C:\Users\85620\AppData\Roaming\npm\node_modules\expo-cli\src\commands\installAsync.ts:55:12)

Screenshot1

当我尝试这个命令yarn add react-native-svg时,我收到了这个错误

yarn add react-native-svg
error Running this command will add the dependency to the workspace root rather than the workspace itself, which might not be what you want - if you really meant it, make it explicit by running this command again with the -W flag (or --ignore-workspace-root-check).
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Screenshot2

有什么建议吗?我是 Expo 和 React Native 的新手。

【问题讨论】:

  • 欢迎您!请将错误文本发布为文本(引用格式),而不是图像。
  • 已编辑,请检查。

标签: react-native svg expo yarnpkg


【解决方案1】:

根据这个话题why does yarn warn when adding a dependency to the root workspaces package.json,现在我可以用下面的命令安装了。

yarn workspace mobile-app add react-native-svg

【讨论】:

    【解决方案2】:

    也许你应该使用 expo 命令

    expo install react-native-svg
    

    【讨论】:

    • 其实我之前输入过"expo install react-native-svg"这一行。之后,“yarn add react-native-svg”这一行会自动出现在下面,然后是上面的错误代码,如您在屏幕截图链接中所见。我已经编辑了帖子,请查看截图链接。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-13
    • 1970-01-01
    • 2022-08-21
    • 1970-01-01
    相关资源
    最近更新 更多