npx command not found

if you are using Linux system, use sudo command

sudo npm i -g npx

Remove NodeJs and npm in your system and reinstall it with the following commands:

Uninstallation

sudo apt remove nodejs
sudo apt remove npm

Fresh Installation

sudo apt install nodejs
sudo apt install npm

Configuration optional, in some cases users may face permission errors.

  1. user defined directory where npm will install packages

    mkdir ~/.npm-global
    
  2. configure npm

    npm config set prefix '~/.npm-global'
    
  3. add directory to path

    echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.profile
    
  4. refresh path for the current session

    source ~/.profile
    
  5. cross-check npm and node modules installed successfully in our system

    node -v
    npm -v
    

Installation of npx

sudo npm i -g npx
npx -v

Well done, we are ready to go. Now you can easily use npx anywhere in your system.


npx should come with npm 5.2+, and you have node 5.6 .. I found that when I install node using nvm for Windows, it doesn't download npx. so just install npx globally:

npm i -g npx

In Linux or Mac OS, if you found any permission related errors use sudo before it.

sudo npm i -g npx