ionic4打包时遇到的种种问题

接触ionic的项目好几个月了,但是在打包时还会遇到各种莫名其妙的错误,今天起决定把遇到的错误都好好记录一下。

Something went wrong installing the “sharp” module

报错截图(在我执行ionic cordova platform add ios命令后报错):
ionic4打包时遇到的种种问题_第1张图片
大概意思是我的sharp版本不对,百度了一通后终于找到执行以下命令可以正确安装上

然后终于可以成功添加ios平台了
在这里插入图片描述

期间遇到的坑:
遇到报错
info sharp Using cached /Users/xmm/.npm/_libvips/libvips-8.8.1-darwin-x64.tar.gz
ERR! sharp Please delete /Users/xmm/.npm/_libvips/libvips-8.8.1-darwin-x64.tar.gz as it is not a valid tarball
ERR! sharp zlib: unexpected end of file
info sharp Attempting to build from source via node-gyp but this may fail due to the above error
info sharp Please see https://sharp.pixelplumbing.com/page/install for required dependencies
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
^~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/sharp/src/common.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:210:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Darwin 19.0.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/xmm/node_modules/sharp
gyp ERR! node -v v12.13.1
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open ‘/Users/xmm/package.json’
npm WARN xmm No description
npm WARN xmm No repository field.
npm WARN xmm No README data
npm WARN xmm No license field.

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/xmm/.npm/_logs/2019-12-03T10_52_58_570Z-debug.log

这个错误把应该是libvips-8.8.1-darwin-x64.tar.gz没下载好,删掉就好了

你可能感兴趣的:(ionic4打包时遇到的种种问题)