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
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
if you are using Linux system, use sudo
command
sudo npm i -g npx
check versions of node, npm, npx as given below. if npx is not installed then use npm i -g npx
node -v
npm -v
npx -v
if you are using macOS, use sudo command
sudo npm install -g npx
Updating node helped me, whether that be from the command line or just re-downloading it from the web
I returned to a system after a while, and even though it had Node 12.x, there was no npx
or even npm
available. I had installed Node via nvm
, so I removed it, reinstalled it and then installed the latest Node LTS. This got me both npm
and npx
.