命令 npm install swiper 失败 - 代码 255

emi*_*err 3 node.js npm swiper.js

当我尝试运行npm installswiper 时会抛出错误。我尝试在本地和全局安装 swiper:

npm install swiper
npm install -g swiper
Run Code Online (Sandbox Code Playgroud)

我在全球范围内成功安装了它。但是当我尝试再次安装时,错误是相同的。

这是错误:

npm ERR! code 255
npm ERR! path C:\Users\Emir\Desktop\Project\portal\node_modules\swiper
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c 
C:\Users\Emir\AppData\Local\Temp\postinstall-cab5f01a.cmd
npm ERR! "Love Swiper? Support Vladimir's work by donating or pledging on patreon:"
npm ERR! The syntax of the command is incorrect.
Run Code Online (Sandbox Code Playgroud)

ben*_*123 6

嘿,你可能是像我一样的 Windows 用户。

我通过设置环境变量修复了此错误

swiper postinstall 文件有问题

https://github.com/nolimits4web/swiper/blob/master/src/copy/postinstall.js

你需要绕过这个

function isBannerRequired() {
  return !(ADBLOCK || CI || DISABLE_OPENCOLLECTIVE || SILENT || OPEN_SOURCE_CONTRIBUTOR);
}
Run Code Online (Sandbox Code Playgroud)

所以在 vs code 中打开一个终端并写入以绕过相等性测试

 $env:OPEN_SOURCE_CONTRIBUTOR="true"
Run Code Online (Sandbox Code Playgroud)

然后尝试 npm install