Skip to content

Troubleshooting

Tommy Nguyen edited this page Feb 27, 2022 · 15 revisions

Contents

Error: project.projectFile invalid. Error: No app project file found, please specify in react-native.config.

On react-native-windows 0.63, autolinking seems to no longer respect the --sln flag. We can work around this by manually specifying the project path:

const path = require("path");

if (
  process.argv.includes("--config=metro.config.windows.js") ||
  process.argv.includes("run-windows")
) {
  const sourceDir = "windows";
  module.exports = {
    project: {
      windows: {
        sourceDir,
        project: {
          projectFile: path.relative(
            path.join(__dirname, sourceDir),
            path.join(
              "node_modules",
              ".generated",
              "windows",
              "ReactTestApp",
              "ReactTestApp.vcxproj"
            )
          ),
        },
      },
    },
    reactNativePath: "node_modules/react-native-windows",
  };
} else {
  ...
}

Failed to construct transformer : error : EBUSY: resource busy or locked, open '~\msbuild.ProjectImports.zip'

This is a known issue in MSBuild (https://github.com/dotnet/msbuild/issues/5383). The workaround is to add this file to blacklistRE in metro.config.js:

module.exports = {
  resolver: {
    blacklistRE: blacklist([
      /node_modules\/.*\/node_modules\/react-native\/.*/,
      /node_modules\/react-native-macos\/.*/,

      // Workaround for `EBUSY: resource busy or locked, open '~\msbuild.ProjectImports.zip'`
      // when building with `yarn windows --release`
      /.*\.ProjectImports\.zip/,
    ]),
  },
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: false,
      },
    }),
  },
};

Invalid Podfile file: undefined method `[]' for nil:NilClass

This can occur if your package is iOS specific, i.e. it contains no ios folder with an Xcode project. react-native config cannot detect your package if this is missing. We can work around it by adding a dummy project to react-native.config.js at the root of the package:

module.exports = {
  project: {
    ios: {
      project: "ReactTestApp-Dummy.xcodeproj",
    },
  },
};

There is no memory profiling because "Address Sanitizer" is enabled

image

For security reasons, Address Sanitizer is enabled by default. You can disable it by editing the scheme as documented in Diagnosing Memory, Thread, and Crash Issues Early.

Your project does not reference "UAP,Version=v10.0" framework

This error may occur when with react-native-windows 0.68 and above. Add Directory.Build.props to the root of your repository with the following content:

<?xml version="1.0" encoding="utf-8"?>
<Project>
  <PropertyGroup Label="NuGet" Condition="'$(MSBuildProjectExtension)' == '.vcxproj'">
    <ResolveNuGetPackages>false</ResolveNuGetPackages>
  </PropertyGroup>
</Project>
Clone this wiki locally