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

时间:2019-05-11 16:24:37

标签: 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

由于fsevents安装失败,因为缺少node-canvas-prebuilt,我无法安装webpack。

我该怎么办?

1 个答案:

答案 0 :(得分:1)

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

我建议您按照每个项目通过npm安装the official documentation中的安装说明:

npm install --save-dev webpack
npm install --save-dev webpack-cli
# or for a one-liner just do npm i webpack webpack-cli

请注意,我们不建议全局安装WebPack(npm i -g webpack,而是为每个项目安装WebPack,以便可以并行使用不同版本的工具。将WebPack与来自不同开发时期的项目一起使用时,这将使您将来的生活更加轻松。