Skip to content

Fixing React Native build error nvm is not compatible with the “PREFIX” environment variable

While building a base of the React Native app for iOS, using the yarn ios command, I got the following error that took me half an hour to figure out what was wrong:

nvm is not compatible with the "PREFIX" environment variable: currently set to "/usr/local"
Run `unset PREFIX` to unset it.
Command PhaseScriptExecution failed with a nonzero exit code

Reading some StackOverflow made me realize that I have node and yarn installed via HomeBrew on my macOS.

╰─❯ ls -la /usr/local/bin/node
lrwxr-xr-x 1 user admin 30 Jun 19 2020 /usr/local/bin/node -> ../Cellar/node/14.4.0/bin/node

But I also have nvm on my machine, and these two installations were clashing. So I have uninstalled the node and yarn

brew uninstall node yarn

installed the desired node version via nvm . See the article about installing nvm and ecosystem that helped me refresh all commands.

nvm install <node-version>

Verify that node and npm are now taken from nvm path:

╰─❯ which node
/Users/user/.nvm/versions/node/v14.16.0/bin/node

And install yarn

╰─❯ npm install -g yarn
...
╰─❯ which yarn
/Users/user/.nvm/versions/node/v14.16.0/bin/yarn

And that’s it. After this yarn ios passed without problems.