【发布时间】:2021-10-14 13:20:24
【问题描述】:
我刚刚开始学习 node 并从 Udemy 上的一门课程中做出反应(课程于去年上传 - 2020 年)。我知道,当我尝试做同样的事情时,导师使用的代码可能已经过时了,但除了尝试安装 axios 之外,我没有收到任何安装任何东西的漏洞。我已经在全球范围内安装了 npm,创建了一个 react 应用程序(create-react-app)并使用了 express,所有这些都可以正常工作。安装 axios 时我缺少什么吗?
这是我得到的错误:
npm WARN @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@7.15.4 requires a peer of @babel/core@^7.13.0 but none is installed. You must install peer dependencies yourself.
npm WARN tsutils@3.21.0 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\watchpack-chokidar2\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\webpack-dev-server\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ axios@0.23.0
updated 1 package and audited 1911 packages in 10.84s
153 packages are looking for funding
run `npm fund` for details
found 27 vulnerabilities (8 moderate, 18 high, 1 critical)
run `npm audit fix` to fix them, or `npm audit` for details
它说尝试运行npm audit fix,但是当我这样做时,它说我必须手动修复这些问题。 Axios 确实存在于我的 package.json 中。
"dependencies": {
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"axios": "^0.23.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"web-vitals": "^1.1.2"
}
这些只是依赖项。我需要修复这些漏洞,还是我的程序会继续正常运行?
【问题讨论】:
-
Axios 0.23 没问题。如果你使用 create-react-app,你会遇到 npm audit 的警告和问题。这是 Facebook 负责 create-react-app 的 React 负责人的一篇文章,解释了原因:overreacted.io/npm-audit-broken-by-design
-
所以我不用担心有什么损坏?我之所以担心,是因为一年前我正在上一门这样的课程(一门 React Native 课程),当一个组件失败时,我不知道该怎么办。
-
我建议忽略这些警告并专注于您的课程作业。只有当您计划发布到生产环境时,警告才会成为问题,即便如此,它们也是逐案发生的。