簡體   English   中英

在Windows 10 Bash上安裝webpack(在Windows上的Ubuntu上進行Bash)。 繼續“webpack:command not found”

[英]Installing webpack on Windows 10 Bash (Bash on Ubuntu on Windows). Keep getting “webpack: command not found”

我正在通過這個React / Redux教程 ,我需要安裝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

我認為這是Windows Bash shell的一個問題,但我在Ubuntu VM上確認了同樣的問題,並做了一些挖掘。 以超級用戶身份全局安裝使其正常工作:

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

當我安裝這樣的webpack時遇到了同樣的問題:“sudo npm install --save-dev webpack”它給我帶來了同樣的錯誤:“webpack:command not found”,我正在使用Ubuntu 16.04。 全局安裝它修復了問題:sudo npm install --save-dev webpack -g“

tl; dr:嘗試$ node_modules\\.bin\\webpack

我想這不是一個bash問題,而是一般用於Windows的節點(以及任何帶有cli的包)。 (這是因為我有任何貝殼這樣的)。 要解決這個問題,請檢查以下幾

  1. 確保安裝了node_modules\\.bin\\webpack.cmd :檢查項目文件夾中的node_modules\\.bin\\webpack.cmd 它應該存在。 注意 :如果你用-g對它進行了安裝,你需要檢查它...NodeJS\\core\\node_modules_global\\
  2. 如何啟動shell以使用Node? nodevars.bat NodeJS\\core有一個nodevars.bat ,你需要在使用Node之前每次運行以設置一些環境(抱歉,我不熟悉你的bash shell,所以你需要找到預先運行這個bat文件的方法)
  3. 最后,您需要確保在Pathnode_modules\\.bin ,這是您看到webpack: command not found主要原因。 只需將此路徑(相對於node_modules\\.bin或絕對D:\\your_project_path\\node_modules\\.bin )添加到Path var。 (或嘗試通過node_modules\\.bin\\webpack.com運行它

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM