microsoft / vscode-react-native

VSCode extension for React Native - supports debugging and editor integration

Home Page:https://marketplace.visualstudio.com/items?itemName=vsmobile.vscode-react-native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Random failures when launching Expo scenarios

SounD120 opened this issue Β· comments

πŸ› What is the bug? How can we reproduce it?

Sometimes Expo fails to launch with strange errors. But if we run Expo several times after that - it launches without any problems.

  1. Launch Debug in Exponent scenario
  2. See random XDL failures like Socket hang up, Module .vscode/exponentIndex.js does not exist in Haste module map
  3. QR Code is not rendered

Expected behavior

Expo works without problems

  • React Native Tools extension version: 0.16.0
  • Expo SDK version (if applicable): 37

#1337
This error may appear when running React Native apps via Expo on macOS:

Error: Unable to resolve module `./.vscode/exponentIndex` from ``: 

None of these files exist:
  * .vscode/exponentIndex(.native|.android.expo.ts|.native.expo.ts|.expo.ts|.android.expo.tsx|.native.expo.tsx|.expo.tsx|.android.expo.js|.native.expo.js|.expo.js|.android.expo.jsx|.native.expo.jsx|.expo.jsx|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.wasm|.native.wasm|.wasm)
  * .vscode/exponentIndex/index(.native|.android.expo.ts|.native.expo.ts|.expo.ts|.android.expo.tsx|.native.expo.tsx|.expo.tsx|.android.expo.js|.native.expo.js|.expo.js|.android.expo.jsx|.native.expo.jsx|.expo.jsx|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.wasm|.native.wasm|.wasm)

This may happen because Metro may not cache this file to Haste map. To solve this problem you can:

  • Restart Packager
  • Add the following lines to metro.config.js:
module.exports.watchFolders = ['.vscode'];

Steps to solve the problem were added in #1337, #1338.

commented

@JiglioNero @SounD120 This issue is still relevant in 2023, there is already a watchFolders: ['.vscode'] setting added to my metro.config.js, still getting the following error:

Error: Unable to resolve module ./.vscode/exponentIndex from /Users/username/Desktop/my-app/.:

None of these files exist:
  * .vscode/exponentIndex(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.svg|.native.svg|.svg|.android.gif|.native.gif|.gif)
  * .vscode/exponentIndex/index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.svg|.native.svg|.svg|.android.gif|.native.gif|.gif)
    at ModuleResolver.resolveDependency (/Users/username/Desktop/my-app/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:136:15)
    at DependencyGraph.resolveDependency (/Users/username/Desktop/my-app/node_modules/metro/src/node-haste/DependencyGraph.js:231:43)
    at /Users/username/Desktop/my-app/node_modules/metro/src/lib/transformHelpers.js:129:24
    at Server._resolveRelativePath (/Users/username/Desktop/my-app/node_modules/metro/src/Server.js:1137:12)
    at async Server.requestProcessor [as _processBundleRequest] (/Users/username/Desktop/my-app/node_modules/metro/src/Server.js:464:37)
    at async Server._processRequest (/Users/username/Desktop/my-app/node_modules/metro/src/Server.js:420:9)

metro.config.js:

const { getDefaultConfig } = require('@expo/metro-config');
module.exports = (async () => {
    const {
        resolver: { sourceExts, assetExts },
    } = await getDefaultConfig(__dirname);
    return {
        resolver: {
            assetExts: [...assetExts, 'gif'].filter(ext => ext !== 'svg'),
            sourceExts: [...sourceExts, 'svg', 'gif'],
        },
        transformer: {
            assetPlugins: ['expo-asset/tools/hashAssetFiles'],
        },
        watchFolders: ['.vscode'],
    };
})();

package.json:

"expo": "^46.0.0",
"react-native": "0.69.6",
"react": "18.0.0",

project type: Expo Bare react native project

I checked my .vscode folder and only found a launch.json file...

I'm actually trying to run a expo dev client build on my physical device.
What I do is: (after building a dev client on EAS servers and installing it on android physical device):-

  1. yarn start -c (to start the server)
  2. scanned the qr generated from above command, launches the app and the error is thrown as mentioned above.

Any solution to this? as the above mentioned didn't work as expected...