繁体   English   中英

npm ci 在 linux 上失败

[英]npm ci failing on linux

当前行为:

我在 mac 上有一个本地开发环境,我从中 git push 到我的远程仓库。 我的生产服务器在 linxu 上,我在那里拉了我的 repo。 通常这很好用,但这次我遇到了一个错误,我找不到解决方法:( npm ci由于fsevents而在 linux 上fsevents

重现步骤:

$ npm ci

npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for fsevents@2.2.1: wanted {"os":"darwin"} (current: {"os":"linux","arch":"x64"})
npm ERR! notsup Valid OS:    darwin
npm ERR! notsup Valid Arch:  undefined
npm ERR! notsup Actual OS:   linux
npm ERR! notsup Actual Arch: x64

我试过的:

  • 删除本地 node_modules & package-lock.json $ rm package-lock.json $ rm -rf node_modules

  • 通过$ sudo npm i -g npm更新全局$ sudo npm i -g npm

  • 通过$ npm install重新安装本地 node_modules

  • 执行$ npm ci

  • 也试过$ npm cache --force clean

  • 还尝试了$ npm audit fix

问题:我无法找出导致问题的依赖项,因为我的 Mac 上一切正常。 但是我的 google cloud linux 服务器似乎在fsevents方面存在问题,因为它不兼容。 我不知道如何修复它或我应该删除什么。 因此,由于发生此错误,我无法再使用我的服务器。

我的 package.json

{
  "name": "app-ant",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@dnd-kit/core": "^3.0.3",
    "@google-cloud/storage": "^5.8.3",
    "@react-pdf/renderer": "^2.0.14",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "antd": "^4.15.1",
    "array-move": "^3.0.1",
    "axios": "^0.21.1",
    "bizcharts": "^4.1.9",
    "core-js": "3.3",
    "cross-env": "^7.0.3",
    "exif-js": "^2.3.0",
    "file-saver": "^2.0.5",
    "firebase": "^8.7.1",
    "framer-motion": "^4.1.17",
    "gantt-schedule-timeline-calendar": "^3.6.6",
    "google-map-react": "^2.1.9",
    "google-maps-react": "^2.0.6",
    "i": "^0.3.6",
    "intl-tel-input": "^17.0.12",
    "moment-timezone": "^0.5.33",
    "npm": "^6.14.12",
    "react": "^16.8.0",
    "react-beautiful-dnd": "^13.1.0",
    "react-color": "^2.19.3",
    "react-csv": "^2.0.3",
    "react-dom": "^16.14.0",
    "react-firebase-hooks": "^3.0.4",
    "react-full-screen": "^1.0.2",
    "react-geocode": "^0.2.3",
    "react-google-autocomplete": "^1.2.6",
    "react-google-charts": "^3.0.15",
    "react-infinite-scroller": "^1.2.4",
    "react-places-autocomplete": "^7.3.0",
    "react-quill": "^1.3.5",
    "react-router-dom": "^5.2.0",
    "react-scripts": "^4.0.3",
    "react-shortcuts": "^2.1.0",
    "react-simple-maps": "^2.3.0",
    "react-sortable-hoc": "^1.11.0",
    "react-to-print": "^2.12.4",
    "react-tracking": "^8.1.0",
    "react-transition-group": "^2.9.0",
    "recharts": "^2.0.9",
    "typescript": "^4.2.4",
    "vcards-js": "^2.10.0",
    "vcf": "^2.1.0",
    "xmp-js": "0.0.5"
  },
  "scripts": {
    "start": "cross-env HOST=website.com react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@iconify-icons/bx": "^1.1.0",
    "@iconify-icons/el": "^1.1.0",
    "@iconify-icons/mdi": "^1.1.14",
    "@iconify/react": "^1.1.4"
  }
}

npm_dependencies_tree 输出: npm ls --all

https://drive.google.com/file/d/1-yZ289sT3kOUPtb-KzewwSlGdF22jXZ6/view?usp=sharing

预先感谢您对我的问题的支持。

这是一个众所周知的问题,在 macOS 上运行时,您的包依赖项之一需要fs-events

当 Node.js 在 Linux 上运行时,不需要这个包,并且由于您使用了--ci标志,它无法在 Linux 上安装fs-events

您可以尝试删除--ci标志,也可以尝试在包文件的optionalDependencies中添加fs-events

"optionalDependencies": {
  "fsevents": "*"
},

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM