安装“sharp”模块时出错

问题描述 投票:0回答:5

我已经按照错误所说的做了。我然后把锐器取下来

npm install --ignore-scripts=false --verbose
,但还是不行。

我也尝试过:

rimraf node_modules 
rimraf yarn.lock 
yarn

这里可能出现什么问题?

npm:6.13.4

节点:v10.18.0

python:3.7.0

锐利:^0.26.2

Windows 10 专业版 64 位

!  Error: 
Something went wrong installing the "sharp" module      

\\?\C:\Users\ph2200009\Desktop\TM\cplus_incident_mgnt\functions\node_modules\sharp\build\Release\sharp.node is not a valid Win32 application.
\\?\C:\Users\ph2200009\Desktop\TM\cplus_incident_mgnt\functions\node_modules\sharp\build\Release\sharp.node     

- Remove the "node_modules/sharp" directory then run    
  "npm install --ignore-scripts=false --verbose" and look for errors

at Object.<anonymous> (C:\Users\ph2200009\Desktop\TM\cplus_incident_mgnt\functions\node_modules\sharp\lib\constructor.js:34:9)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)  
    at Object.<anonymous> (C:\Users\ph2200009\Desktop\TM\cplus_incident_mgnt\functions\node_modules\sharp\lib\index.js:3:15)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)  
    at Object.<anonymous> (C:\Users\ph2200009\Desktop\TM\cplus_incident_mgnt\functions\helpers\image.js:1:15)   
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
!  We were unable to load your functions code. (see above)
reactjs npm-install sharp
5个回答
8
投票

如果您有 Apple M1 芯片,请尝试以下操作:

brew install vips

npm rebuild --verbose sharp

2
投票

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

npm rebuild --verbose sharp

0
投票

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

npm rebuild --arch=arm64 --platform=linux sharp

0
投票

只是想记录一下什么代码为我自己解决了这个问题。这是纱线加锋利


-1
投票

尝试通过在终端中键入

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

© www.soinside.com 2019 - 2024. All rights reserved.