How to solve the react-native-webview no such file directory '.../windows/ReactNativeWebView\ReactNativeWebView.vcxproj' issue

Viewed 185

Just cloned my clients existing app and used yarn to install all the packages. However on trying to build an apk encountered following error.

error ENOENT: no such file or directory, open '/app/node_modules/react-native-webview/windows/ReactNativeWebView\ReactNativeWebView.vcxproj'

on checking the node_modules/react-native-webview/windows/ReactNativeWebView, I discovered that the file actually exists.

1 Answers

This probably is related to the [linking issue of react-native-webview for windows][1]

Ahead is what I found as the quick-fix for tackling this error ENOENT: no such file or directory, open '/app/node_modules/react-native-webview/windows/ReactNativeWebView\ReactNativeWebView.vcxproj' error in particular

I am not sure if this is just a type from the contributed of the lib. Anyways, make the following changes in the react-native.config.js file of the react-native-webview package

projects: [
        {
          projectFile: 'ReactNativeWebView/ReactNativeWebView.vcxproj', //replace the '\\' in the path with a forward slash '/'
          directDependency: true,
        },
        {
          projectFile: 'WebViewBridgeComponent/WebViewBridgeComponent.vcxproj', //replace the '\\' in the path with a forward slash '/'
          directDependency: false,
        }
      ],
    },

Orignal was as follows -

 windows: {
      sourceDir: 'windows',
      solutionFile: 'ReactNativeWebView.sln',
      projects: [
        {
          projectFile: 'ReactNativeWebView\\ReactNativeWebView.vcxproj',
          directDependency: true,
        },
        {
          projectFile: 'WebViewBridgeComponent\\WebViewBridgeComponent.vcxproj',
          directDependency: false,
        }
      ],
    },

I know making changes to the files in node-modules is not a good practice at all. But it seems to be working for now.

will be sure to update an appropriate fix when/if I find it [1]: https://github.com/react-native-webview/react-native-webview/blob/master/docs/Getting-Started.md#windows

Related