我尝试在我的nuxt项目中使用它,但编译失败
在我的plugin/sharp.js中
import vue from "vue"
import sharp from "sharp"
vue.use(sharp)
我还需要我的nuxt.config.js
plugins: [
'~plugins/sharp.js',
],
编译时,我的终端出错
Failed to compile with 4 errors friendly-errors 01:16:19
These dependencies were not found: friendly-errors 01:16:19
friendly-errors 01:16:19
* child_process in ./node_modules/detect-libc/lib/detect-libc.js, ./node_modules/sharp/lib/libvips.js friendly-errors 01:16:19
* fs in ./node_modules/detect-libc/lib/detect-libc.js, ./node_modules/sharp/lib/libvips.js friendly-errors 01:16:19
friendly-errors 01:16:19
To install them, you can run: npm install --save child_process fs
1条答案
按热度按时间zc0qhyus1#
sharp是一个node.js包,因此它不适用于vue。至少,不是在客户端上下文中。
您最好提前或通过cloudinary之类的服务优化图像。