尝试安装Sharp for Gatsby时出错

Error when trying to install Sharp for Gatsby

我是使用盖茨比的新手。 我可以使用Gatsby的默认启动程序,但是其他任何启动程序似乎都依赖Sharp,无论我做什么都无法安装。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
    info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.6.1/libvips-8.6.1-darwin-x64.tar.gz
/Users/djfriar/Sites/gatsby-pretty/node_modules/sharp/install/libvips.js:76
          throw err;
          ^

Error: self signed certificate in certificate chain
    at TLSSocket.onConnectSecure (_tls_wrap.js:1049:34)
    at TLSSocket.emit (events.js:182:13)
    at TLSSocket._finishInit (_tls_wrap.js:631:8)
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: self signed certificate in certificate chain
gyp ERR! stack     at TLSSocket.onConnectSecure (_tls_wrap.js:1049:34)
gyp ERR! stack     at TLSSocket.emit (events.js:182:13)
gyp ERR! stack     at TLSSocket._finishInit (_tls_wrap.js:631:8)
gyp ERR! System Darwin 18.2.0
gyp ERR! command"/usr/local/bin/node""/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js""rebuild"
gyp ERR! cwd /Users/djfriar/Sites/gatsby-pretty/node_modules/sharp
gyp ERR! node -v v10.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/djfriar/.npm/_logs/2018-12-30T06_05_17_559Z-debug.log
error Command failed: npm install

有人知道我在这里可能会想念的吗?


尝试删除您的node_modulespackage-lock.json(如果使用npm)或yarn.lock(如果使用yarn)。

与npm

1
2
3
$ rm -rf node_modules package-lock.json
$ npm install
$ npm run build

带纱

1
2
3
$ rm -rf node_modules yarn.lock
$ yarn
$ yarn build

这为我解决了这个问题。 看来我的yarn.lock与我的Node版本冲突并导致了错误。

如果这对您不起作用,请查看此GitHub问题或此问题,其中提到了其他潜在的修复程序。


我在json包中将" sharp":" ^ 0.21"更改为" sharp":" ^ 0.22.1",终于成功了。