首页 > 解决方案 > expo install react-native-svg“错误运行此命令会将依赖项添加到工作区根目录而不是工作区本身......”

问题描述

我正在使用世博会 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)

截图1

当我尝试这个命令时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.

截图2

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

标签: react-nativesvgexpoyarnpkg

解决方案


也许你应该使用 expo 命令

expo install react-native-svg

推荐阅读