expoyarn-v2

Error: @expo/cli tried to access glob, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound


I just created new react-native expo project via yarn 2. And getting error:

Error yarn start:

PS D:\Files\Projects\my-rn-journey\other-navigators> yarn start
D:\Files\Projects\my-rn-journey\other-navigators\.pnp.cjs:21723
      Error.captureStackTrace(firstError);
            ^

Error: @expo/cli tried to access glob, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: glob
Required by: @expo/cli@npm:0.7.3 (via D:\Files\Projects\my-rn-journey\other-navigators\.yarn\cache\@expo-cli-npm-0.7.3-b8fe3aaa8f-f1b03efbec.zip\node_modules\@expo\cli\build\src\utils\)

Require stack:
- D:\Files\Projects\my-rn-journey\other-navigators\.yarn\cache\@expo-cli-npm-0.7.3-b8fe3aaa8f-f1b03efbec.zip\node_modules\@expo\cli\build\src\utils\glob.js
- D:\Files\Projects\my-rn-journey\other-navigators\.yarn\cache\@expo-cli-npm-0.7.3-b8fe3aaa8f-f1b03efbec.zip\node_modules\@expo\cli\build\src\start\doctor\typescript\TypeScriptProjectPrerequisite.js
- D:\Files\Projects\my-rn-journey\other-navigators\.yarn\cache\@expo-cli-npm-0.7.3-b8fe3aaa8f-f1b03efbec.zip\node_modules\@expo\cli\build\src\start\startAsync.js
- D:\Files\Projects\my-rn-journey\other-navigators\.yarn\cache\@expo-cli-npm-0.7.3-b8fe3aaa8f-f1b03efbec.zip\node_modules\@expo\cli\build\src\start\index.js
- D:\Files\Projects\my-rn-journey\other-navigators\.yarn\cache\@expo-cli-npm-0.7.3-b8fe3aaa8f-f1b03efbec.zip\node_modules\@expo\cli\build\bin\cli
    at require$$0.Module._resolveFilename (D:\Files\Projects\my-rn-journey\other-navigators\.pnp.cjs:21723:13)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at require$$0.Module._load (D:\Files\Projects\my-rn-journey\other-navigators\.pnp.cjs:21612:31)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (D:\Files\Projects\my-rn-journey\other-navigators\.yarn\cache\@expo-cli-npm-0.7.3-b8fe3aaa8f-f1b03efbec.zip\node_modules\@expo\cli\build\src\utils\glob.js:8:13)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at require$$0.Module._extensions..js (D:\Files\Projects\my-rn-journey\other-navigators\.pnp.cjs:21767:33)
    at Module.load (node:internal/modules/cjs/loader:1119:32)

Node.js v18.16.1

App.js is blank. Just contains hello world text.


Solution

  • I've just noticed expo doesn't support Plugnplay that comes from yarn v2. So we need node_modules.

    Just run these:

    > yarn config set nodeLinker node-modules
    > yarn