Search code examples
reactjsreact-nativenpmnpxenoent

what is the difference between npm install -g react-native-cli versus using npx react-native init <project name>?


**what is the difference between setting up react-native- cli with npm install -g react-native-cli and init versus using npx react-native init ?

I recently got a lot of eneont errors while developing react-native app. firstly i setup my system with npm install -g react-native and was working fine but later while installing dependencies they got eneont errors like could not find fsevent, nanoid, hammerjs etc. And the official documentation includes setup to use npx. I really got confused with this sort of approach. could you please light some knowledge on npm vs npx and installing with '-g' argument?


Solution

  • npx is a npm package runner (x probably stands for eXecute). The typical use is to download and run a package temporarily or for trials.

    With npm you install the package on your machine. And global makes it available to all your projects not only the one where you currently work in.