0

I'm using Expo CLI. I want to use SVG in React Native. So, I follow an instruction from here https://github.com/react-native-svg/react-native-svg. But when I installed expo install react-native-svg I received the following error:

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

And when I tried this command yarn add react-native-svg, I received this error

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

Any suggestion? I'm new to Expo and React Native.

Boon
  • 21
  • 5

2 Answers2

0

Maybe you should use expo command

expo install react-native-svg
Michael Bahl
  • 2,941
  • 1
  • 13
  • 16
  • Actually, I enter this line "expo install react-native-svg" before. After that this line "yarn add react-native-svg" automatically comes below and followed by the error code above as you can see in the screenshot link. I've edited the post, please check the screenshot link. – Boon Aug 11 '21 at 07:27
0

According to this topic why does yarn warn when adding a dependency to the root workspaces package.json, now I can install it with the following command.

yarn workspace mobile-app add react-native-svg
Boon
  • 21
  • 5