npm ci在linux上失败

6ojccjat  于 2021-10-10  发布在  Java
关注(0)|答案(1)|浏览(276)

当前行为:
我在mac上有一个本地开发环境,我可以从这个环境将git推送到远程repo。我的生产服务器在linxu,在那里我拉我的回购。通常这很好,但这次我遇到了一个错误,我找不到解决方法:( npm ci 在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

我所尝试的:
删除本地节点_模块&package-lock.json
$ rm package-lock.json `$ rm -rf node_modules` 通过以下方式更新全球npm: `$ sudo npm i -g npm` 通过以下方式重新安装本地节点_模块: `$ npm install` 执行 `$ npm ci` 也试过 `$ npm cache --force clean` 也试过 `$ npm audit fix` 问题:我无法找出是什么依赖性导致了这个问题,因为在我的mac上一切都正常。但是我的google cloud linux服务器似乎有问题 `fsevents` 因为这是不相容的。我不知道如何修复它,也不知道应该删除什么。因此,发生此错误后,我无法再使用我的服务器。
mypackage.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_依赖项_树输出: `npm ls --all` https://drive.google.com/file/d/1-yz289st3kouptb-kzewwslgdf22jxz6/view?usp=sharing
提前感谢您对我问题的支持。
6za6bjd0

6za6bjd01#

这是一个众所周知的问题,是您的包依赖项之一 fs-events 在macos上运行时。
当node.js在linux上运行时,不需要这个包,因为您正在使用 --ci 标志,则无法安装 fs-events 在linux上。
您可以尝试删除 --ci 标记,或者您可以尝试添加 fs-events 在里面 optionalDependencies 在您的包文件中。

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

相关问题