node.js 找不到 npx 命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49894620/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
npx command not found
提问by wokoro douye samuel
I am working with webpack and I need to execute ./node_modules/webpack/bin/webpack.jsusing npx. npx webpackwould run the webpack binary (./node_modules/webpack/bin/webpack), but each time I execute npx webpack I get
bash: npx: command not found.
我正在使用 webpack,我需要./node_modules/webpack/bin/webpack.js使用npx. npx webpack将运行 webpack 二进制文件 ( ./node_modules/webpack/bin/webpack),但每次执行 npx webpack 时我都会得到
bash: npx: command not found.
I am using:
我在用:
node: v9.5.0
npm: 5.6.0
nvm: 1.1.5
webpack: 3.11.0
节点:v9.5.0
npm:5.6.0
虚拟机:1.1.5
网络包:3.11.0
回答by Bar Horing
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:
npx 应该与 npm 5.2+ 一起提供,并且您有节点 5.6 .. 我发现当我使用 nvm for Windows 安装节点时,它不会下载 npx。所以只需全局安装 npx:
npm i -g npx
In Linuxor MacOS, if you found any permission related errors use sudo before it.
在Linux或MacOS 中,如果您发现任何与权限相关的错误,请在它之前使用 sudo。
sudo npm i -g npx
回答by Rajitha Fernando
if you are using Linux system, use sudocommand
如果您使用的是 Linux 系统,请使用sudo命令
sudo npm i -g npx
回答by Golam Sorwar
回答by Arafath
check versions of node, npm, npx as given below. if npx is not installed then use npm i -g npx
检查 node、npm、npx 的版本,如下所示。如果未安装 npx 则使用npm i -g npx
node -v
npm -v
npx -v
回答by Brian Sunbury
Updating node helped me, whether that be from the command line or just re-downloading it from the web
更新节点对我有帮助,无论是从命令行还是从网上重新下载
回答by aalaap
I returned to a system after a while, and even though it had Node 12.x, there was no npxor even npmavailable. I had installed Node via nvm, so I removed it, reinstalled it and then installed the latest Node LTS. This got me both npmand npx.
过了一会儿我又回到了一个系统,即使它有 Node 12.x,也没有npx甚至npm可用。我通过 安装了 Node nvm,所以我删除了它,重新安装了它,然后安装了最新的 Node LTS。这让我npm和npx.
回答by dipenparmar12
Remove NodeJs and npm in your system and reinstall it by following commands
删除系统中的 NodeJs 和 npm 并通过以下命令重新安装
Uninlstallation
卸载
sudo apt remove nodejssudo apt remove npm
sudo apt remove nodejssudo apt remove npm
Fresh Installation
全新安装
sudo apt install nodejssudo apt install npm
sudo apt install nodejssudo apt install npm
Configurationoptional, in some cases users may face permission errors.
配置可选,在某些情况下用户可能会面临权限错误。
user defined directory where npm will install packages
mkdir ~/.npm-globalconfigure npm
npm config set prefix '~/.npm-global'add directory to path
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.profilerefresh path for the current session
source ~/.profilecross-check npm and node modules installed successfully in our system
node -vnpm -v
用户定义的 npm 将安装包的目录
mkdir ~/.npm-global配置 npm
npm config set prefix '~/.npm-global'将目录添加到路径
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.profile当前会话的刷新路径
source ~/.profile交叉检查在我们的系统中成功安装的 npm 和节点模块
node -vnpm -v
Installation of npx
安装 npx
sudo npm i -g npxnpx -v
sudo npm i -g npxnpx -v
Well-done we are ready to go... now you can easily use npxanywhere in your system.
干得好,我们准备好了……现在您可以轻松地npx在系统中的任何地方使用。


