npx command not found
node.jsNpmWebpackNpxnode.js Problem Overview
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
node.js Solutions
Solution 1 - node.js
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
Solution 2 - node.js
if you are using Linux system, use sudo
command
sudo npm i -g npx
Solution 3 - node.js
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.
-
user defined directory where npm will install packages
mkdir ~/.npm-global
-
configure npm
npm config set prefix '~/.npm-global'
-
add directory to path
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.profile
-
refresh path for the current session
source ~/.profile
-
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.
Solution 4 - node.js
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
Solution 5 - node.js
Solution 6 - node.js
Updating node helped me, whether that be from the command line or just re-downloading it from the web
Solution 7 - node.js
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
.
Solution 8 - node.js
sudo apt install npm
install npm first
(it will take around 177MB node also will get installed along with this cmd) space
Install npx
sudo npm i -g npx
Check the version of the installed npm,node,npx (for confirming latest release and installed or no it will show) using
nod -v npx -v npm -v
Solution 9 - node.js
1. First step:
check and install your node version with node -v
.
2. second step:
check and install your npm version with npm -v
.
If you still have a problem,might your command is npx create_react_app your_app_name
instead of npx create-react-app your_app_name
.
Solution 10 - node.js
check node -v,npm -v, npx -v if are you getting output in the terminal but if you are executing these commands inside terminal of any IDE's like VSCODE, ATOM ... etc then reinstall that IDE.
Solution 11 - node.js
- I went to the documentation of vs-code (mentioned below on recourses section)
- Initially they ask to check the execution policy by executing
Get-ExecutionPolicy
on power shell of vs-code -> I got Restricted - Next
Get-ExecutionPolicy -List
to get all of the execution policies with their scorps. And I got the follwing result :/
>MachinePolicy Undefined
> Process Undefined
CurrentUser Undefined
LocalMachine Undefined
-
Then I rechecked the error which was displayed at the beginning, in vs-code power shell
'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' is denied. To change the execution policy
execution policy for the current user, run "Set-ExecutionPolicy -Scope CurrentUser". -
In there too it's mentioned the err is about the current-user
-
So I execute
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
-
And it worked for me. It's pleasure if this would work to you too thanks.
Solution 12 - node.js
try :
sudo su
then
npm i npx
or
npi i -g npx
check your npx version by
npx -v