osx由于缺少相关性而无法安装webpack

Har*_*rry 5 macos npm webpack

没人能得到这个吗?

node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@0.10.3
node-pre-gyp info using node@11.15.0 | darwin | x64
node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp info check checked for "/Users/aaa/Documents/projects/sweetalert/node_modules/canvas-prebuilt/canvas/build/Release/canvas-prebuilt.node" (not found)
node-pre-gyp http GET https://github.com/chearon/node-canvas-prebuilt/releases/download/v1.6.11/canvas-prebuilt-v1.6.11-node-v67-darwin-x64.tar.gz
node-pre-gyp http 404 https://github.com/chearon/node-canvas-prebuilt/releases/download/v1.6.11/canvas-prebuilt-v1.6.11-node-v67-darwin-x64.tar.gz
node-pre-gyp ERR! install error 
node-pre-gyp ERR! stack Error: 404 status code downloading tarball https://github.com/chearon/node-canvas-prebuilt/releases/download/v1.6.11/canvas-prebuilt-v1.6.11-node-v67-darwin-x64.tar.gz
node-pre-gyp ERR! stack     at Request.<anonymous> (/Users/aaa/Documents/projects/sweetalert/node_modules/canvas-prebuilt/node_modules/node-pre-gyp/lib/install.js:137:27)
node-pre-gyp ERR! stack     at Request.emit (events.js:198:15)
node-pre-gyp ERR! stack     at Request.onRequestResponse (/Users/aaa/Documents/projects/sweetalert/node_modules/request/request.js:1066:10)
node-pre-gyp ERR! stack     at ClientRequest.emit (events.js:193:13)
node-pre-gyp ERR! stack     at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:560:23)
node-pre-gyp ERR! stack     at HTTPParser.parserOnHeadersComplete (_http_common.js:113:17)
node-pre-gyp ERR! stack     at TLSSocket.socketOnData (_http_client.js:447:22)
node-pre-gyp ERR! stack     at TLSSocket.emit (events.js:193:13)
node-pre-gyp ERR! stack     at addChunk (_stream_readable.js:295:12)
node-pre-gyp ERR! stack     at readableAddChunk (_stream_readable.js:276:11)
node-pre-gyp ERR! System Darwin 18.0.0
Run Code Online (Sandbox Code Playgroud)

我无法安装webpack,因为fsevents安装失败是因为缺少预构建的node-canvas。

我能做什么?

Sia*_*vas 1

通过 Homebrew 进行的安装似乎已经过时,因为它尝试安装 1.6.11 版本canvas-prebuilt,该版本于 2017 年左右发布,现已不再可用。最接近的版本是 1.6.15。

我建议您按照官方文档npm中的安装说明在每个项目的基础上安装它:

npm install --save-dev webpack
npm install --save-dev webpack-cli
# or for a one-liner just do npm i webpack webpack-cli
Run Code Online (Sandbox Code Playgroud)

请注意,建议全局安装 WebPack ( npm i -g webpack),而是为每个项目安装它,以便可以并行使用该工具的不同版本。这将使您将来在使用 WebPack 处理来自不同开发时间的项目时变得更轻松。