Skip to content

Expo开发解决问题的过程 #10

Open
@timi-black

Description

@timi-black

expo start --web -c (清缓存启动)

Your JavaScript transform cache is empty, rebuilding (this may take a minute).
Starting Webpack on port 19006 in production mode.
[=================== ] 95% (11.0 seconds)(node:52976) UnhandledPromiseRejectionWarning: Error: It was not possible to generate splash screen '/usr/local/lib/node_modules/expo-cli/node_modules/@expo/webpack-config/web-default/icon.png'. This command requires version 1.10.0 of `sharp-cli`. 
You can install it using `npm install -g sharp-cli@1.10.0`. 

For prerequisites, see: https://sharp.dimens.io/en/stable/install/#prerequisites
    at new IconError (/@expo/webpack-pwa-manifest-plugin@1.2.4/src/errors/IconError.js:2:20)

根据提示安装

npm i -g npm sharp-cli@1.10.0

又报错了

/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
/usr/local/bin/sharp -> /usr/local/lib/node_modules/sharp-cli/bin/cli.js

> sharp@0.22.1 install /usr/local/lib/node_modules/sharp-cli/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.7.4/libvips-8.7.4-darwin-x64.tar.gz
/usr/local/lib/node_modules/sharp-cli/node_modules/sharp/install/libvips.js:83
          throw err;
          ^

Error: unable to verify the first certificate
    at TLSSocket.onConnectSecure (_tls_wrap.js:1058:34)
    at TLSSocket.emit (events.js:198:13)
    at TLSSocket._finishInit (_tls_wrap.js:636:8)
  TOUCH Release/obj.target/libvips-cpp.stamp
  CXX(target) Release/obj.target/sharp/src/common.o
../src/common.cc:25:10: fatal error: 'vips/vips8' file not found
#include <vips/vips8>
         ^~~~~~~~~~~~

image

根据错误提示搜索问题

brew install vips

安装成功后再次尝试

npm install -g sharp-cli@1.10.0

 sharp@0.22.1 install /usr/local/lib/node_modules/sharp-cli/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

info sharp Detected globally-installed libvips v8.8.1
info sharp Building from source via node-gyp
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libffi', required by 'gobject-2.0', not found
gyp: Call to 'PKG_CONFIG_PATH="/usr/lib/pkgconfig:/usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/10.14:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig" pkg-config --cflags-only-I vips-cpp vips glib-2.0 | sed s\/-I//g' returned exit status 0 while in binding.gyp. while trying to load binding.gyp

根据提示

image

vim ~/.bash_profile
添加:
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/usr/local/opt/libffi/lib/pkgconfig"
image

source ~/.bash_profile

再试尝试

npm install -g sharp-cli@1.10.0

终于成功了

XYSZM01652:~ wutianmei$ npm install -g sharp-cli@1.10.0
/usr/local/bin/sharp -> /usr/local/lib/node_modules/sharp-cli/bin/cli.js

> sharp@0.22.1 install /usr/local/lib/node_modules/sharp-cli/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

info sharp Detected globally-installed libvips v8.8.1
info sharp Building from source via node-gyp
  TOUCH Release/obj.target/libvips-cpp.stamp
  CXX(target) Release/obj.target/sharp/src/common.o
  CXX(target) Release/obj.target/sharp/src/metadata.o
  CXX(target) Release/obj.target/sharp/src/stats.o
  CXX(target) Release/obj.target/sharp/src/operations.o
  CXX(target) Release/obj.target/sharp/src/pipeline.o
  CXX(target) Release/obj.target/sharp/src/sharp.o
  CXX(target) Release/obj.target/sharp/src/utilities.o
  SOLINK_MODULE(target) Release/sharp.node
+ sharp-cli@1.10.0
added 134 packages from 118 contributors in 48.834s

总结

  • 安装包的过程中解决问题的方案往往都可以在错误提示中找到
  • 使用 cnpmyarn有时并不能成功安装所有的包,当多次尝试无果时我们要回到根源使用npm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions