Skip to content

Troubleshooting

Tommy Nguyen edited this page Jul 19, 2021 · 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",
    },
  },
};
Clone this wiki locally