尝试使用以下 npm 命令来安装
redux
、react-datepicker
和 react-router-dom
。
npm i react-redux @reduxjs/toolkit react-datepicker react-router-dom@6
我注意到 package.json 没有更新,并且终端中输出以下内容:
up to date, audited 157 packages in 16s
22 packages are looking for funding
run `npm fund` for details
15 high severity vulnerabilities
To address issues that do not require attention, run:
npm audit fix
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
检查 Stackoverflow 后,我尝试了
npm set registry=https://registry.npmjs.org/
。
如何解决这个问题?
包.json
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
期待
react-datepicker
,react-redux
,以及其他要在此处添加的。
已安装软件包,但漏洞警告只是只是警告,通常可以忽略。如果您想更新/修复它们,请运行
npm audit fix
。
确保您位于安装项目依赖项的正确目录中,然后尝试使用:
npm i -S react-redux @reduxjs/toolkit react-datepicker react-router-dom@6
这应该安装 并 更新 package.json 文件。
-S
或 --save
标志在较旧的 Node 和 NPM 版本中执行此操作。