[英]Can't install Gatsby starter theme because of Sharp module failing
[英]Can't install Sharp
運行sudo npm i sharp --save
出現以下錯誤:
> sharp@0.21.3 install /home/server/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
info sharp Using cached /home/ronny/.npm/_libvips/libvips-8.7.0-linux-x64.tar.gz
ERR! sharp EACCES: permission denied, mkdir '/home/server/node_modules/sharp/vendor'
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
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/server/node_modules/sharp/build'
gyp ERR! System Linux 4.18.0-13-generic
gyp ERR! command "/usr/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/server/node_modules/sharp
gyp ERR! node -v v8.11.4
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN server@1.0.0 No description
npm WARN server@1.0.0 No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp@0.21.3 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 sharp@0.21.3 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! /home/ronny/.npm/_logs/2019-01-28T20_33_46_476Z-debug.log
我在另一台機器上運行了相同的項目,在那里,安裝完美無缺。 但是在我的另一台機器上(都運行 Linux Ubuntu)我遇到了上述錯誤。
我找不到此錯誤的任何解決方案。 這就是為什么我在這里尋求幫助。
這對我有用。 npm install --unsafe-perm
請參考以下討論https://github.com/lovell/sharp/issues/1627#issuecomment-477109851
最簡單的方法是:
brew uninstall vips
接着:
npm install
對於Apple M1 brew install vips
然后npm install --unsafe-perm
如果它不能解決您的問題,請在此類似問題中找到更多信息
- xcode-選擇--安裝
- 釀造安裝 gcc
- brew重新安裝vips
- 釀造信息貴賓
- npm 我
Node v13.14.0+的問題,問題就解決了
npm install sharp@0.23.2
如果您使用的是 sharp 0.22.1,則應將 Node 版本降級為 >=10.0.0
這實際上幫助了我,使用節點 14.20.1
npm install sharp --ignore-scripts
我通過將node version to 10.0.0
解決了這個錯誤。 真的行!
刪除package-lock.json和node_modules
然后嘗試安裝軟件包npm install
為我工作。
npm install --arch=x64 --platform=linux sharp
為我工作
取自: https ://github.com/lovell/sharp/issues/2128#issuecomment-600232917
我正在使用M1 mac
所以首先錯誤說權限被拒絕。 使用安裝它sudo
當您在銳利的文檔中使用sudo
時! 它說你必須使用npm install --unsafe-perm
我會推薦:
/home/ronny/.npm/_libvips/libvips-8.7.0-linux-x64.tar.gz
(在您的錯誤代碼中)libvips-8.7.0-linux-x64.tar.gz
npm install --unsafe-perm
(這將安裝已刪除的庫)npm install sharp
那我覺得我應該好好工作。 這些步驟解決了我的問題,我遇到了同樣的問題。 希望能幫助到你。 謝謝。
嘗試使用 yarn 而不是 npm,它對我有用(docker,官方節點映像 16.x)
yarn add sharp
我的 Apple M1 遇到了同樣的問題,我運行了下一個命令:
brew install vips
npm install --unsafe-perm
它有效
晚了,但我告訴你什么對我有用。 如果您之前安裝了任何與 sharp 完全相同的依賴項,請從您的Package.json
文件中刪除該dependency
項,然后運行
npm install sharp
我也有這個問題。 我安裝了所需的 (6Gb,.) Visual Studio 2022 Build 工具,但即使在重新啟動后它仍然無法正常工作。
我嘗試的另一件事是設置以下內容:
npm config set msbuild_path "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe"
仍然沒有用。
最后,我刪除node_modules
和package-lock.json
。 我從package.json
中刪除了 sharp 模塊並安裝了所有東西。
然后我跑:
npm install sharp --save
終於成功了
在 Windows 上運行 npx create-strapi-app my-project --quickstart 並得到相同的錯誤,必須從 Visual Studio 安裝 C++ 進行桌面開發並且它工作。
就我而言,我必須先安裝 Python。 之后,一切順利。 在此處安裝 Python。
npm i sharp
npm ERR! code 1
npm ERR! gyp ERR! find Python
gyp ERR! stack at PythonFinder
您可以嘗試的另一件事是打開任務管理器並終止當前正在運行的節點 js 進程
npm 安裝 --unsafe-perm -g cordova-res
npm 安裝 --platform=darwin --arch=x64 sharp
https://sharp.pixelplumbing.com/install
我正在使用 Macbook pro M1 nodeJS 版本 v16.14.2 它適用於我
對我來說,閱讀日志幫助我找到了解決方案。
紗output:
➤ YN0009: │ sharp@npm:0.30.7 couldn't be built successfully (exit code 1, logs can be found here: /private/var/folders/yc/78ts3g2s4mxdbxsln5kz16dm0000gn/T/xfs-49e52cab/build.log)
在那個日志文件中,我注意到了這一行:
env: python: No such file or directory
我只有一個python3
二進制文件,沒有python
,所以我將python3
符號鏈接到/usr/local/bin/python
,這讓我可以安裝 sharp。
ln -sf $(which python3) /usr/local/bin/python
Linux/Ubuntu:我遇到了這個問題。 節點版本 18.12.1,但首先嘗試安裝 node-gyp
sudo npm install -g node-gyp
然后刪除舊的package-lock.json
並再次嘗試安裝
注意:如果你沒有修復它。 請查看sharp-installation guide
我在執行“npm install”之前添加了一個命令。
- USER=`whoami` && sudo chown $USER:$USER .
- npm install --verbose
# node => 16
# npm => 8.11.0
# sharp => 0.31.3
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.