React-Native claims to let people write once and run everywhere. So today, I decided to have it at my PC. And I don’t want it on my local drive, as its available space is becoming more and more precious. So, I decided it to install it on one of my mapped network drive, say “U:”.

Before installing react-native, you may need to install git first and run the following command to set email and name.

git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git config --global --add safe.directory "//192.168.x.y/mount-point/project-name"

The installation process is listed on the Get Started with Windows page, which gives the following command line that can be easily completed in Windows CMD.

npx react-native@nightly init <projectName> --version "nightly"

And you may have noticed the “nightly” word. This is a bit too aggressive. I wanted the latest release version. Therefore, I switched “latest” for “nightly” and ran the following line.

npx react-native@latest init project-name --version "latest" --verbose
cd project-name
npx react-native-windows-init --overwrite

This command ran smoothly to its end.

Now, I ran:

npx react-native run-windows

However, it claimed lack of dependencies. And I needed to run on an elevated powershell:

U:\project-name\node_modules\react-native-windows\scripts\rnw-dependencies.ps1

But before it, I have to switch to the drive U: in powershell. This time, I got the following error:

Powershell did not share the same drive mapping as in CMD/File Explorer!

Here is what came to rescue. I needed to map the network drive under powershell. The following was the command.

PS C:\WINDOWS\system32> New-PSDrive -Name U -Root \\192.168.x.y\network-mount -PSProvider FileSystem

After it, I was able to switch to U: in powershell. BTW, if you need to keep the U: drive permanently, you just need to add a “-Persist” argument to the command line above.

Run the following commands to install dependencies.

Set-ExecutionPolicy Unrestricted -Scope Process -Force;
U:\project-name\node_modules\react-native-windows\scripts\rnw-dependencies.ps1

Or, you can run the following instead, as introduced on the System Requirements page.

Set-ExecutionPolicy Unrestricted -Scope Process -Force;
iex (New-Object System.Net.WebClient).DownloadString('https://aka.ms/rnw-vs2022-deps.ps1');

The installation process ends here. However, my turmoil did not end here. This command did not end successfully. It could not run WindowsStoreAppUtils.ps1 due to powershell execution policy. I bypassed this problem by editing the following file:

U:\project-name\node_modules\@react-native-windows\cli\lib-commonjs\utils\commandWithProgress.js

Find the string '-NoProfile' in the file, and add two lines below it:

            '-ExecutionPolicy',
            'ByPass',

Now you can run:

npx react-native run-windows --logging

The above adjustments helped me to successfully build a debug version. However, registering the app will fail, because the app resided on a network drive. After searching on the Internet, it seems that registering an app on network drive is simply not supported.

I also tried running through Visual Studio, but the result was the same.

DEP0700: Registration of the app failed. [0x80073D1F]

Bad luck! At least, I learned that react-native-windows apps cannot be developed on network drives, because you cannot debug it.

Later, I tried build without running, and I succeeded. This is what I did:

"C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64\MakeCert" /n "CN=project-name" /r /h 0 /eku "1.3.6.1.5.5.7.3.3,1.3.6.1.4.1.311.10.3.13" /e "12/31/2100" /sv project-name.pvk project-name.cer

"C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64\Pvk2Pfx" /pvk project-name.pvk /spc project-name.cer /pfx project-name.pfx

You may have to change the blue and red parts above to match your projects. These commands create three files.

project-name.cer
project-name.pvk
project-name.pfx

The .cer file is the certificate file. You need to find in the file explorer, double click to import it into your PC. Be sure to import it into local machine, not current user. Put it into the “Trusted Root Certification Authorities” store. Otherwise, app install will not succeed.

The .pfx file will be the one that you use to sign your app package. Select “From File …” when building app package in VisualStudio.

As a note, be sure to build in Release settings. For otherwise, the app will not run. As it will not successfully connect to the local server port, even if you started the server.

Good luck!