npx command not found

wokoro douye samuel picture wokoro douye samuel · Apr 18, 2018 · Viewed 107.9k times · Source

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:

  • node: v9.5.0

  • npm: 5.6.0

  • nvm: 1.1.5

  • webpack: 3.11.0

Answer

Bar Horing Amir picture Bar Horing Amir · Jul 7, 2018

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