reactjs 安装“sharp”模块时出错

u0njafvf  于 2023-10-17  发布在  React
关注(0)|答案(5)|浏览(194)

我已经做了错误所说的。我删除了尖锐然后npm install --ignore-scripts=false --verbose,但它仍然不工作。
我也试过了:

  1. rimraf node_modules
  2. rimraf yarn.lock
  3. yarn

这里有什么问题吗?
npm:6.13.4
节点:v10.18.0
Python:3.7.0
锐:^0.26.2
windows 10 pro 64-bit

  1. ! Error:
  2. Something went wrong installing the "sharp" module
  3. \\?\C:\Users\ph2200009\Desktop\TM\cplus_incident_mgnt\functions\node_modules\sharp\build\Release\sharp.node is not a valid Win32 application.
  4. \\?\C:\Users\ph2200009\Desktop\TM\cplus_incident_mgnt\functions\node_modules\sharp\build\Release\sharp.node
  5. - Remove the "node_modules/sharp" directory then run
  6. "npm install --ignore-scripts=false --verbose" and look for errors
  7. at Object.<anonymous> (C:\Users\ph2200009\Desktop\TM\cplus_incident_mgnt\functions\node_modules\sharp\lib\constructor.js:34:9)
  8. at Module._compile (internal/modules/cjs/loader.js:778:30)
  9. at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
  10. at Module.load (internal/modules/cjs/loader.js:653:32)
  11. at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
  12. at Function.Module._load (internal/modules/cjs/loader.js:585:3)
  13. at Module.require (internal/modules/cjs/loader.js:692:17)
  14. at require (internal/modules/cjs/helpers.js:25:18)
  15. at Object.<anonymous> (C:\Users\ph2200009\Desktop\TM\cplus_incident_mgnt\functions\node_modules\sharp\lib\index.js:3:15)
  16. at Module._compile (internal/modules/cjs/loader.js:778:30)
  17. at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
  18. at Module.load (internal/modules/cjs/loader.js:653:32)
  19. at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
  20. at Function.Module._load (internal/modules/cjs/loader.js:585:3)
  21. at Module.require (internal/modules/cjs/loader.js:692:17)
  22. at require (internal/modules/cjs/helpers.js:25:18)
  23. at Object.<anonymous> (C:\Users\ph2200009\Desktop\TM\cplus_incident_mgnt\functions\helpers\image.js:1:15)
  24. at Module._compile (internal/modules/cjs/loader.js:778:30)
  25. at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
  26. at Module.load (internal/modules/cjs/loader.js:653:32)
  27. at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
  28. at Function.Module._load (internal/modules/cjs/loader.js:585:3)
  29. ! We were unable to load your functions code. (see above)
mfuanj7w

mfuanj7w1#

如果您使用的是Apple M1芯片,请尝试以下操作:

  1. brew install vips
  2. npm rebuild --verbose sharp
blmhpbnm

blmhpbnm2#

我使用这个rebuild命令来修复它:

  1. npm rebuild --verbose sharp
fhg3lkii

fhg3lkii3#

对于我的Apple M1芯片,这是唯一有效的方法:

  1. npm rebuild --arch=arm64 --platform=linux sharp
yshpjwxd

yshpjwxd4#

我只是想记录下我自己是怎么解决这个问题的这是

  1. yarn add sharp
sc4hvdpw

sc4hvdpw5#

尝试通过在终端中键入rm -rf node_modules删除node_modules文件夹,然后键入npm i,然后再次尝试通过npm i sharp安装sharp

相关问题