本文介绍了在Windows 10 Bash上安装webpack(在Windows上的Ubuntu上安装Bash).继续获取"webpack:找不到命令";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过 React/Redux教程,我需要安装webpack.我正在使用Windows 10 bash shell.这是我用来安装的npm命令以及安装输出:

I'm working my way through this React/Redux tutorial and I need to install webpack. I'm working on the Windows 10 bash shell. Here's the npm command I use to install and the installation output:

~$ npm install --save-dev webpack webpack-dev-server
[email protected] /home/username/voting-client
+-- [email protected]
¦ +-- [email protected]
¦ +-- [email protected]
¦ +-- [email protected]
¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ +-- [email protected]
¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦   +-- [email protected]
¦ ¦   +-- [email protected]
¦ ¦   +-- [email protected]
¦ ¦   +-- [email protected]
¦ ¦   +-- [email protected]
¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ ¦ +-- [email protected]
¦ ¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ ¦ +-- [email protected]
¦ ¦ ¦ +-- [email protected]
¦ ¦ ¦ +-- [email protected]
¦ ¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ ¦ +-- [email protected]
¦ ¦ ¦ +-- [email protected]
¦ ¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ ¦ +-- [email protected]
¦ ¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦   +-- [email protected]
¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ +-- [email protected]
¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦   +-- [email protected]
¦ ¦   +-- [email protected]
¦ ¦   ¦ +-- [email protected]
¦ ¦   ¦ ¦ +-- [email protected]
¦ ¦   ¦ ¦ ¦ +-- [email protected]
¦ ¦   ¦ ¦ ¦ +-- [email protected]
¦ ¦   ¦ ¦ +-- [email protected]
¦ ¦   ¦ +-- [email protected]
¦ ¦   ¦ +-- [email protected]
¦ ¦   +-- [email protected]
¦ ¦   +-- [email protected]
¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦ +-- [email protected]
¦ ¦   +-- [email protected]
¦ ¦   ¦ +-- [email protected]
¦ ¦   +-- [email protected]
¦ ¦   +-- [email protected]
¦ ¦   +-- [email protected]
¦ ¦   ¦ +-- [email protected]
¦ ¦   +-- [email protected]
¦ ¦   +-- [email protected]
¦ ¦     +-- [email protected]
¦ ¦     ¦ +-- [email protected]
¦ ¦     ¦   +-- [email protected]
¦ ¦     ¦   +-- [email protected]
¦ ¦     +-- [email protected]
¦ +-- [email protected]
¦   +-- [email protected]
¦   +-- [email protected]
¦     +-- [email protected]
+-- [email protected]
  +-- [email protected]
  ¦ +-- [email protected]
  ¦ ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  +-- [email protected]
  +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ ¦ +-- [email protected]
  ¦ ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ ¦ +-- [email protected]
  ¦ ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ ¦ +-- [email protected]
  ¦ +-- [email protected]
  +-- [email protected]
  ¦ +-- [email protected]
  ¦ ¦ +-- [email protected]
  ¦ ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦   +-- [email protected]
  ¦   ¦ +-- [email protected]
  ¦   +-- [email protected]
  ¦   +-- [email protected]
  ¦   ¦ +-- [email protected]
  ¦   ¦ ¦ +-- [email protected]
  ¦   ¦ ¦   +-- [email protected]
  ¦   ¦ ¦   +-- [email protected]
  ¦   ¦ ¦   +-- [email protected]
  ¦   ¦ +-- [email protected]
  ¦   ¦ +-- [email protected]
  ¦   +-- [email protected]
  ¦   ¦ +-- [email protected]
  ¦   +-- [email protected]
  ¦   +-- [email protected]
  ¦   +-- [email protected]
  ¦   +-- [email protected]
  ¦   ¦ +-- [email protected]
  ¦   +-- [email protected]
  ¦   +-- [email protected]
  ¦   ¦ +-- [email protected]
  ¦   ¦ ¦ +-- [email protected]
  ¦   ¦ +-- [email protected]
  ¦   +-- [email protected]
  ¦   ¦ +-- [email protected]
  ¦   ¦ +-- [email protected]
  ¦   +-- [email protected]
  ¦     +-- [email protected]
  ¦     +-- [email protected]
  +-- [email protected]
  +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ ¦ +-- [email protected]
  ¦ +-- [email protected]
  +-- [email protected]
  ¦ +-- [email protected]
  ¦ ¦ +-- [email protected]
  ¦ ¦   +-- [email protected]
  ¦ +-- [email protected]
  +-- [email protected]
  ¦ +-- [email protected]
  ¦ ¦ +-- [email protected]
  ¦ ¦   +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦ +-- [email protected]
  ¦   +-- [email protected]
  +-- [email protected]
  +-- [email protected]
  ¦ +-- [email protected]
  +-- [email protected]
    +-- [email protected]
    +-- [email protected]
    +-- [email protected]

npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]

因此,除了两个警告外,它看起来像已安装,并且我认为我不需要fsevents.但是,当我尝试运行webpack时,它的行为就像未安装.

So besides the two warnings, it looks like it installs, and I don't think I needs fsevents. However, when I try to run webpack it acts like it's not installed.

~$ webpack
webpack: command not found

推荐答案

我认为这是Windows Bash shell的问题,但是我在Ubuntu VM上确认了同样的问题,并且做了更多的挖掘工作.以超级用户身份进行全局安装可以使其正常工作:

I thought this was an issue with the Windows Bash shell, but I confirmed the same problem on an Ubuntu VM and did some more digging. Installing globally as superuser got it working:

sudo npm install i -g --save-dev webpack webpack-dev-server

这篇关于在Windows 10 Bash上安装webpack(在Windows上的Ubuntu上安装Bash).继续获取"webpack:找不到命令";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 07:07