Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
545 views
in Technique[技术] by (71.8m points)

reactjs - Install sharp without GitHub fetch for Nextjs: Error: Cannot find module 'sharp'

I'm trying to use Next.js on my corporate system, but whenever I run "npm run build", the build fails with the message: Error: Cannot find module 'sharp'

I tried installing sharp but I get this error:

info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.10.5/libvips-8.10.5-win32-x64.tar.br 
ERR! sharp getaddrinfo ENOTFOUND github.com 
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/install for required dependencies

This is probably because github URLs are blocked on my system's terminal due to security reasons. Is there a way to install sharp without fetching from github? I can access GitHub on the browser, so if downloading the file from there and then installing it somehow is possible I can do that.

OS: Windows 10

question from:https://stackoverflow.com/questions/65894000/install-sharp-without-github-fetch-for-nextjs-error-cannot-find-module-sharp

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I had the same error. It was happening to me because I have the Apple M1 Mac. I solved the error installing Homebrew, and after that, I had to install 'lipvips' using Brew install vips. Then, inside my project, npm install sharp, and finally, I run npm run build and it worked fine for me. I Hope It works for you!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...