node.jsnpmwebpacknpx

npx command not found


I am working with webpack and I need to execute ./node_modules/webpack/bin/webpack.js using npx. npx webpack would run the webpack binary (./node_modules/webpack/bin/webpack), but each time I execute npx webpack I get bash: npx: command not found.

I am using:


Solution

  • 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