在Windows 10 Bash上安装webpack(在Windows上的Ubuntu上进行Bash)。继续“webpack:command not found”

时间:2016-12-23 02:56:37

标签: windows bash ubuntu npm webpack

我正在努力完成这个React/Redux tutorial,我需要安装webpack。我正在使用Windows 10 bash shell。这是我用来安装的npm命令和安装输出:

~$ npm install --save-dev webpack webpack-dev-server
voting-client@1.0.0 /home/username/voting-client
+-- webpack@1.14.0
¦ +-- acorn@3.3.0
¦ +-- async@1.5.2
¦ +-- clone@1.0.2
¦ +-- enhanced-resolve@0.9.1
¦ ¦ +-- graceful-fs@4.1.11
¦ ¦ +-- memory-fs@0.2.0
¦ +-- interpret@0.6.6
¦ +-- loader-utils@0.2.16
¦ ¦ +-- big.js@3.1.3
¦ ¦ +-- emojis-list@2.1.0
¦ ¦ +-- json5@0.5.1
¦ ¦ +-- object-assign@4.1.0
¦ +-- memory-fs@0.3.0
¦ ¦ +-- errno@0.1.4
¦ ¦ ¦ +-- prr@0.0.0
¦ ¦ +-- readable-stream@2.2.2
¦ ¦   +-- buffer-shims@1.0.0
¦ ¦   +-- core-util-is@1.0.2
¦ ¦   +-- isarray@1.0.0
¦ ¦   +-- process-nextick-args@1.0.7
¦ ¦   +-- util-deprecate@1.0.2
¦ +-- mkdirp@0.5.1
¦ ¦ +-- minimist@0.0.8
¦ +-- node-libs-browser@0.7.0
¦ ¦ +-- assert@1.4.1
¦ ¦ +-- browserify-zlib@0.1.4
¦ ¦ ¦ +-- pako@0.2.9
¦ ¦ +-- buffer@4.9.1
¦ ¦ ¦ +-- base64-js@1.2.0
¦ ¦ ¦ +-- ieee754@1.1.8
¦ ¦ +-- console-browserify@1.1.0
¦ ¦ ¦ +-- date-now@0.1.4
¦ ¦ +-- constants-browserify@1.0.0
¦ ¦ +-- crypto-browserify@3.3.0
¦ ¦ ¦ +-- browserify-aes@0.4.0
¦ ¦ ¦ +-- pbkdf2-compat@2.0.1
¦ ¦ ¦ +-- ripemd160@0.2.0
¦ ¦ ¦ +-- sha.js@2.2.6
¦ ¦ +-- domain-browser@1.1.7
¦ ¦ +-- events@1.1.1
¦ ¦ +-- https-browserify@0.0.1
¦ ¦ +-- os-browserify@0.2.1
¦ ¦ +-- path-browserify@0.0.0
¦ ¦ +-- process@0.11.9
¦ ¦ +-- punycode@1.4.1
¦ ¦ +-- querystring-es3@0.2.1
¦ ¦ +-- stream-browserify@2.0.1
¦ ¦ +-- stream-http@2.5.0
¦ ¦ ¦ +-- builtin-status-codes@2.0.0
¦ ¦ ¦ +-- to-arraybuffer@1.0.1
¦ ¦ ¦ +-- xtend@4.0.1
¦ ¦ +-- string_decoder@0.10.31
¦ ¦ +-- timers-browserify@2.0.2
¦ ¦ ¦ +-- setimmediate@1.0.5
¦ ¦ +-- tty-browserify@0.0.0
¦ ¦ +-- url@0.11.0
¦ ¦ ¦ +-- punycode@1.3.2
¦ ¦ ¦ +-- querystring@0.2.0
¦ ¦ +-- util@0.10.3
¦ ¦ ¦ +-- inherits@2.0.1
¦ ¦ +-- vm-browserify@0.0.4
¦ ¦   +-- indexof@0.0.1
¦ +-- optimist@0.6.1
¦ ¦ +-- wordwrap@0.0.3
¦ +-- supports-color@3.1.2
¦ ¦ +-- has-flag@1.0.0
¦ +-- tapable@0.1.10
¦ +-- uglify-js@2.7.5
¦ ¦ +-- async@0.2.10
¦ ¦ +-- source-map@0.5.6
¦ ¦ +-- uglify-to-browserify@1.0.2
¦ ¦ +-- yargs@3.10.0
¦ ¦   +-- camelcase@1.2.1
¦ ¦   +-- cliui@2.1.0
¦ ¦   ¦ +-- center-align@0.1.3
¦ ¦   ¦ ¦ +-- align-text@0.1.4
¦ ¦   ¦ ¦ ¦ +-- longest@1.0.1
¦ ¦   ¦ ¦ ¦ +-- repeat-string@1.6.1
¦ ¦   ¦ ¦ +-- lazy-cache@1.0.4
¦ ¦   ¦ +-- right-align@0.1.3
¦ ¦   ¦ +-- wordwrap@0.0.2
¦ ¦   +-- decamelize@1.2.0
¦ ¦   +-- window-size@0.1.0
¦ +-- watchpack@0.2.9
¦ ¦ +-- async@0.9.2
¦ ¦ +-- chokidar@1.6.1
¦ ¦   +-- anymatch@1.3.0
¦ ¦   ¦ +-- arrify@1.0.1
¦ ¦   +-- async-each@1.0.1
¦ ¦   +-- glob-parent@2.0.0
¦ ¦   +-- is-binary-path@1.0.1
¦ ¦   ¦ +-- binary-extensions@1.8.0
¦ ¦   +-- is-glob@2.0.1
¦ ¦   +-- readdirp@2.1.0
¦ ¦     +-- minimatch@3.0.3
¦ ¦     ¦ +-- brace-expansion@1.1.6
¦ ¦     ¦   +-- balanced-match@0.4.2
¦ ¦     ¦   +-- concat-map@0.0.1
¦ ¦     +-- set-immediate-shim@1.0.1
¦ +-- webpack-core@0.6.9
¦   +-- source-list-map@0.1.7
¦   +-- source-map@0.4.4
¦     +-- amdefine@1.0.1
+-- webpack-dev-server@1.16.2
  +-- compression@1.6.2
  ¦ +-- accepts@1.3.3
  ¦ ¦ +-- negotiator@0.6.1
  ¦ +-- bytes@2.3.0
  ¦ +-- compressible@2.0.9
  ¦ ¦ +-- mime-db@1.25.0
  ¦ +-- debug@2.2.0
  ¦ ¦ +-- ms@0.7.1
  ¦ +-- on-headers@1.0.1
  ¦ +-- vary@1.1.0
  +-- connect-history-api-fallback@1.3.0
  +-- express@4.14.0
  ¦ +-- array-flatten@1.1.1
  ¦ +-- content-disposition@0.5.1
  ¦ +-- content-type@1.0.2
  ¦ +-- cookie@0.3.1
  ¦ +-- cookie-signature@1.0.6
  ¦ +-- depd@1.1.0
  ¦ +-- encodeurl@1.0.1
  ¦ +-- escape-html@1.0.3
  ¦ +-- etag@1.7.0
  ¦ +-- finalhandler@0.5.0
  ¦ ¦ +-- statuses@1.3.1
  ¦ ¦ +-- unpipe@1.0.0
  ¦ +-- fresh@0.3.0
  ¦ +-- merge-descriptors@1.0.1
  ¦ +-- methods@1.1.2
  ¦ +-- on-finished@2.3.0
  ¦ ¦ +-- ee-first@1.1.1
  ¦ +-- parseurl@1.3.1
  ¦ +-- path-to-regexp@0.1.7
  ¦ +-- proxy-addr@1.1.2
  ¦ ¦ +-- forwarded@0.1.0
  ¦ ¦ +-- ipaddr.js@1.1.1
  ¦ +-- qs@6.2.0
  ¦ +-- range-parser@1.2.0
  ¦ +-- send@0.14.1
  ¦ ¦ +-- destroy@1.0.4
  ¦ +-- serve-static@1.11.1
  ¦ +-- type-is@1.6.14
  ¦ ¦ +-- media-typer@0.3.0
  ¦ +-- utils-merge@1.0.0
  +-- http-proxy-middleware@0.17.3
  ¦ +-- http-proxy@1.16.2
  ¦ ¦ +-- eventemitter3@1.2.0
  ¦ ¦ +-- requires-port@1.0.0
  ¦ +-- is-glob@3.1.0
  ¦ ¦ +-- is-extglob@2.1.1
  ¦ +-- lodash@4.17.2
  ¦ +-- micromatch@2.3.11
  ¦   +-- arr-diff@2.0.0
  ¦   ¦ +-- arr-flatten@1.0.1
  ¦   +-- array-unique@0.2.1
  ¦   +-- braces@1.8.5
  ¦   ¦ +-- expand-range@1.8.2
  ¦   ¦ ¦ +-- fill-range@2.2.3
  ¦   ¦ ¦   +-- is-number@2.1.0
  ¦   ¦ ¦   +-- isobject@2.1.0
  ¦   ¦ ¦   +-- randomatic@1.1.6
  ¦   ¦ +-- preserve@0.2.0
  ¦   ¦ +-- repeat-element@1.1.2
  ¦   +-- expand-brackets@0.1.5
  ¦   ¦ +-- is-posix-bracket@0.1.1
  ¦   +-- extglob@0.3.2
  ¦   +-- filename-regex@2.0.0
  ¦   +-- is-extglob@1.0.0
  ¦   +-- kind-of@3.1.0
  ¦   ¦ +-- is-buffer@1.1.4
  ¦   +-- normalize-path@2.0.1
  ¦   +-- object.omit@2.0.1
  ¦   ¦ +-- for-own@0.1.4
  ¦   ¦ ¦ +-- for-in@0.1.6
  ¦   ¦ +-- is-extendable@0.1.1
  ¦   +-- parse-glob@3.0.4
  ¦   ¦ +-- glob-base@0.3.0
  ¦   ¦ +-- is-dotfile@1.0.2
  ¦   +-- regex-cache@0.4.3
  ¦     +-- is-equal-shallow@0.1.3
  ¦     +-- is-primitive@2.0.0
  +-- open@0.0.5
  +-- serve-index@1.8.0
  ¦ +-- batch@0.5.3
  ¦ +-- http-errors@1.5.1
  ¦ ¦ +-- setprototypeof@1.0.2
  ¦ +-- mime-types@2.1.13
  +-- sockjs@0.3.18
  ¦ +-- faye-websocket@0.10.0
  ¦ ¦ +-- websocket-driver@0.6.5
  ¦ ¦   +-- websocket-extensions@0.1.1
  ¦ +-- uuid@2.0.3
  +-- sockjs-client@1.1.1
  ¦ +-- eventsource@0.1.6
  ¦ ¦ +-- original@1.0.0
  ¦ ¦   +-- url-parse@1.0.5
  ¦ +-- faye-websocket@0.11.0
  ¦ +-- inherits@2.0.3
  ¦ +-- json3@3.3.2
  ¦ +-- url-parse@1.1.7
  ¦   +-- querystringify@0.0.4
  +-- stream-cache@0.0.2
  +-- strip-ansi@3.0.1
  ¦ +-- ansi-regex@2.0.0
  +-- webpack-dev-middleware@1.9.0
    +-- memory-fs@0.4.1
    +-- mime@1.3.4
    +-- path-is-absolute@1.0.1

npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.15

除了两个警告之外,它看起来像安装,我认为我不需要fsevents。但是,当我尝试运行webpack时,它就像没有安装一样。

~$ webpack
webpack: command not found

3 个答案:

答案 0 :(得分:1)

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

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

答案 1 :(得分:0)

我安装webpack时遇到了同样的问题,如下所示: " sudo npm install --save-dev webpack"它给我带来了同样的错误:" webpack:命令未找到",我正在研究Ubuntu 16.04。 全局安装它修复了问题:sudo npm install --save-dev webpack -g"

答案 2 :(得分:0)

tl; dr:尝试$ node_modules\.bin\webpack

我想这不是一个bash问题,而是一般用于Windows的节点(以及任何带有cli的包)。 (因为我对任何炮弹都有这种情况)。要解决这个问题,请检查以下几点:

  1. 确保安装了webpack:检查项目文件夹中的node_modules\.bin\webpack.cmd。它应该存在。 (注意:如果您将其与-g联系起来,则需要在...NodeJS\core\node_modules_global\
  2. 中进行检查
  3. 如何启动shell以使用Node?在nodevars.bat NodeJS\core中,您需要在使用Node之前每次运行以设置一些环境(抱歉,我不熟悉您的bash shell,因此您需要找到自己的方式预先运行这个bat文件)
  4. 最后,您需要确保node_modules\.binPath webpack: command not found,这是您看到node_modules\.bin的主要原因。只需将此路径(相对于D:\your_project_path\node_modules\.bin或绝对Path)添加到node_modules\.bin\webpack.com var即可。 (或尝试通过default: &default [...] development_1: <<: *default database: dev1 development_2: <<: *default database: dev2
  5. 运行它