繁体   English   中英

删除 node_modules 后如何解决 npm 安装问题

[英]How do I solve npm install issue after deleting node_modules

I am trying to clean out my react-native project's package to do a clean npm install on a MacOS based system (my windows system for Android development has no issues in cleaning up package versions).

我开始在 npm 安装中看到错误,抱怨版本差异不兼容,并在“rook 项目”和 node_modules/ 目录中列出每个 package 版本之间的差异。

我通过删除 package-lock.json 进行常规修复,删除 node_modules 目录并重新运行 npm 安装。 从我的项目文件夹中。 它立即提出了同样的错误投诉。 问题是这样的,我的项目文件夹中没有 node_modules ,因为我删除了它。 而且它没有创建新的 node_modules 目录。

鉴于此问题,我该如何调试并修复它? 我想了解的问题:

  1. 我如何告诉 npm 告诉我它认为根项目的价值是什么(完整路径)?
  2. 如何告诉 npm 告诉我 node_modules 目录的完整路径似乎在哪里看到?
  3. 最后,我如何强制 npm 做正确的事情并专注于我的项目的附属品,而不是像看起来那样看项目文件夹之外?

我的一些想法。 我不明白为什么要在根项目和 node_modules 之间进行 package cersion 比较?

似乎 nodde 和 npm 在 MacOS 环境中做的事情与在我的 windows 系统环境中做的事情不同——我不明白这一点。

这里的任何人都可以帮助我了解发生了什么以及如何解决它?

错误 output 在这里:

thomas@Presonus americanaradio % npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: AmericanaRadio@0.0.2
npm ERR! Found: react@16.14.0
npm ERR! node_modules/react
npm ERR!   react@"^16.13.1" from the root project
npm ERR!   peer react@"^16.8" from
@react-native-community/async-storage@1.12.1
npm ERR!   node_modules/@react-native-community/async-storage
npm ERR!     @react-native-community/async-storage@"^1.12.1" from the
root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"17.0.2" from react-native@0.66.4
npm ERR! node_modules/react-native
npm ERR!   react-native@"^0.66.3" from the root project
npm ERR!   peer react-native@">=0.59" from
@react-native-community/async-storage@1.12.1
npm ERR!   node_modules/@react-native-community/async-storage
npm ERR!     @react-native-community/async-storage@"^1.12.1" from the
root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency
resolution.
npm ERR!
npm ERR! See /Users/thomas/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/thomas/.npm/_logs/2021-12-10T15_47_02_669Z-debug.log
thomas@Presonus americanaradio %

package.json 内容在这里:

{END)
 "name": "AmericanaRadio",
 "version": "0.0.2",
 "private": true,
 "scripts": {
   "android": "react-native run-android",
   "ios": "react-native run-ios",
   "start": "react-native start",
   "test": "jest",
   "lint": "eslint ."
 },
 "dependencies": {
   "@react-native-community/async-storage": "^1.12.1",
   "@react-native-community/checkbox": "^0.5.2",
   "@react-native-community/masked-view": "^0.1.10",
   "@react-native-community/slider": "^3.0.3",
   "node-fetch": "^2.6.1",
   "react": "^16.13.1",
   "react-native": "^0.66.3",
   "react-native-background-timer": "^2.4.1",
   "react-native-elements": "^3.4.2",
   "react-native-gesture-handler": "^1.9.0",
   "react-native-keyboard-aware-scroll-view": "^0.9.5",
   "react-native-reanimated": "^2.2.4",
   "react-native-safe-area-context": "^3.1.9",
   "react-native-screens": "^2.15.2",
   "react-native-simple-survey": "^3.1.2",
   "react-native-swift": "^1.2.1",
   "react-native-vector-icons": "^8.0.0",
   "react-native-version-check": "^3.4.2",
   "react-native-version-info": "^1.1.0",
   "react-native-webview": "^11.3.1",
   "react-navigation": "^4.4.3",
   "react-navigation-drawer": "^2.6.0",
   "react-navigation-stack": "^2.10.2",
   "react-usestateref": "^1.0.8",
   "socket.io-client": "^4.4.0"
 },
 "devDependencies": {
   "@babel/core": "^7.12.10",
   "@babel/runtime": "^7.12.5",
   "@react-native-community/eslint-config": "^2.0.0",
   "babel-jest": "^26.6.3",
   "eslint": "^7.18.0",
   "jest": "^26.6.3",
   "metro-react-native-babel-preset": "^0.64.0",
   "react-test-renderer": "16.13.1"
 },
 "jest": {
   "preset": "react-native"
 }
}
~
(END)

如我的描述中所述,node_modules 目录已删除并且运行 npm 安装失败并且没有创建 node_modules 目录。 因此,错误消息令人困惑,因为我的项目目录(americanaradio)中没有包。

感谢您查看此内容,希望可以从中找到解决方案。

首先检查哪个库给您错误并尝试重新安装或更新该版本。 也尝试删除节点模块。 然后安装 npm。

暂无
暂无

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

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