【问题标题】:Npm install is giving Error in React-NativeNpm install 在 React-Native 中给出错误
【发布时间】:2021-02-05 03:43:38
【问题描述】:

我试图在我的项目上运行 npm install 我删除了节点模块以重新安装它,但我的终端上出现了很多错误。我所做的只是 npm install 在假定的文件夹中,但仍然出现错误。错误消息位于此消息下方。 谢谢

npm WARN tar ENOENT: no such file or directory, open 'C:\Users\APPname\node_modules\.staging\react-native-441da136\React\CxxModule\RCTCxxMethod.h'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\APPname\node_modules\.staging\react-native-441da136\React\CxxModule\RCTCxxMethod.mm'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\APPname\node_modules\.staging\react-native-441da136\React\CxxModule\RCTCxxModule.h'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\APPname\node_modules\.staging\react-native-441da136\React\CxxModule\RCTCxxModule.mm'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\APPname\node_modules\.staging\react-native-441da136\React\CxxModule\RCTCxxUtils.h'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\APPname\node_modules\.staging\react-native-441da136\React\CxxModule\RCTCxxUtils.mm'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\APPname\node_modules\.staging\react-native-441da136\React\CxxModule\RCTNativeModule.h'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\APPname\node_modules\.staging\react-native-441da136\React\CxxModule\RCTNativeModule.mm'
npm ERR! code E404
npm ERR! 404 Not Found: preset@1.0.0

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\ABC\AppData\Roaming\npm-cache\_logs\2020-10-22T06_34_20_827Z-debug.log

这是我的 package.json 文件

  {
  "name": "App Name",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@datacamp/react-native-linear-gradient": "2.4.2",
    "@dooboo-ui/native-switch-toggle": "0.7.0",
    "@freakycoder/react-native-helpers": "^0.1.3",
    "@paraboly/react-native-card": "^0.3.0",
    "@react-native-community/async-storage": "1.11.0",
    "@react-native-community/blur": "3.6.0",
    "@react-native-community/datetimepicker": "2.6.1",
    "@react-native-community/masked-view": "0.1.10",
    "@react-native-community/netinfo": "5.9.5",
    "@react-native-community/picker": "1.8.0",
    "@react-native-community/slider": "3.0.3",
    "@react-navigation/drawer": "5.9.0",
    "@react-navigation/material-bottom-tabs": "5.2.16",
    "@react-navigation/native": "5.7.3",
    "@react-navigation/stack": "5.9.0",
    "axios": "0.19.2",
    "babel-eslint": "^10.1.0",
    "datejs": "1.0.0-rc3",
    "eslint-config-airbnb": "18.2.0",
    "eslint-config-standard": "14.1.1",
    "eslint-plugin-import": "2.22.0",
    "eslint-plugin-jsx-a11y": "6.3.1",
    "eslint-plugin-node": "11.1.0",
    "eslint-plugin-promise": "4.2.1",
    "eslint-plugin-react": "7.20.5",
    "eslint-plugin-react-native": "3.8.1",
    "eslint-plugin-standard": "4.0.1",
    "expo": "39.0.3",
    "expo-font": "8.3.0",
    "jetifier": "1.6.6",
    "moment": "2.27.0",
    "moment-timezone": "0.5.31",
    "native-base": "2.13.13",
    "preset": "1.0.0",
    "prop-types": "15.7.2",
    "react": "16.13.1",
    "react-highlight-selection": "^1.0.2",
    "react-native": "0.63.2",
    "react-native-animatable": "1.3.3",
    "react-native-bouncy-touchable": "^1.0.0",
    "react-native-cardview": "2.0.5",
    "react-native-chart-kit": "6.4.1",
    "react-native-check-box": "2.1.7",
    "react-native-confetti-cannon": "^1.5.1",
    "react-native-contacts": "^6.0.1",
    "react-native-datepicker": "1.7.2",
    "react-native-device-info": "5.6.5",
    "react-native-document-picker": "3.5.4",
    "react-native-drop-down-item": "1.1.0",
    "react-native-dropdown-picker": "3.6.8",
    "react-native-dynamic-vector-icons": "^1.1.4",
    "react-native-elements": "^2.1.0",
    "react-native-exception-handler": "2.10.8",
    "react-native-extra-dimensions-android": "1.2.5",
    "react-native-firebase": "5.6.0",
    "react-native-gesture-handler": "1.8.0",
    "react-native-google-places-autocomplete": "1.8.3",
    "react-native-google-recaptcha-v2": "1.1.0",
    "react-native-google-signin": "2.1.1",
    "react-native-image-crop-picker": "^0.32.2",
    "react-native-image-slider-box": "1.0.12",
    "react-native-keyboard-aware-scroll-view": "0.9.2",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-localize": "^1.4.1",
    "react-native-masked-text": "^1.13.0",
    "react-native-material-bottom-navigation": "^1.0.5",
    "react-native-material-dropdown": "^0.11.1",
    "react-native-material-menu": "^1.1.3",
    "react-native-modal": "^11.5.6",
    "react-native-modal-datetime-picker": "^8.8.0",
    "react-native-modalize": "2.0.6",
    "react-native-motion-slider": "^1.0.3",
    "react-native-multiple-select": "^0.5.5",
    "react-native-paper": "^4.0.1",
    "react-native-permissions": "^2.1.5",
    "react-native-picker-select": "^8.0.0",
    "react-native-popover-view": "^3.0.3",
    "react-native-push-notification-popup": "^1.4.0",
    "react-native-rate": "^1.2.1",
    "react-native-raw-bottom-sheet": "^2.2.0",
    "react-native-really-awesome-button": "^1.6.0",
    "react-native-reanimated": "^1.10.1",
    "react-native-render-html": "^4.2.2",
    "react-native-responsive-screen": "1.4.1",
    "react-native-restart": "0.0.17",
    "react-native-root-toast": "^3.2.1",
    "react-native-safe-area-context": "^3.1.1",
    "react-native-screens": "^2.9.0",
    "react-native-searchable-dropdown": "^1.1.1",
    "react-native-select-contact": "^1.5.0",
    "react-native-share": "^3.7.0",
    "react-native-signature-capture": "^0.4.10",
    "react-native-simple-radio-button": "^2.7.4",
    "react-native-slider": "^0.11.0",
    "react-native-slideshow": "^1.0.1",
    "react-native-slowlog": "^1.0.2",
    "react-native-smart-statusbar": "^1.0.17",
    "react-native-star-rating": "^1.1.0",
    "react-native-svg": "^12.1.0",
    "react-native-swipe-list-view": "^3.2.3",
    "react-native-swiper": "^1.6.0",
    "react-native-swiper-flatlist": "^2.0.4",
    "react-native-switch-toggle": "^1.1.4",
    "react-native-text-gradient": "^0.1.7",
    "react-native-textinput-effects": "^0.6.1",
    "react-native-vector-icons": "^7.1.0",
    "react-native-video": "^5.1.0-alpha8",
    "react-native-webview": "^10.3.3",
    "react-navigation": "^4.4.0",
    "react-navigation-stack": "^2.8.2",
    "react-navigation-tabs": "^2.9.0",
    "react-phone-number-input": "^3.0.25",
    "react-redux": "^7.2.1",
    "redux": "^4.0.5",
    "rn-fetch-blob": "^0.12.0",
    "styled-components": "^5.2.0",
    "validate.js": "^0.13.1"
  },
  "devDependencies": {
    "@babel/core": "^7.11.1",
    "@babel/runtime": "^7.11.1",
    "@react-native-community/eslint-config": "^2.0.0",
    "babel-jest": "^26.2.2",
    "eslint": "^7.6.0",
    "jest": "^26.2.2",
    "metro-react-native-babel-preset": "^0.61.0",
    "react-test-renderer": "^16.13.1"
  },
  "rnpm": {
    "assets": [
      "./assets/fonts"
    ]
  },
  "assetBundlePatterns": [
    "assets/images/*"
  ],
  "jest": {
    "preset": "react-native"
  }

}

【问题讨论】:

  • 分享日志文件
  • 日志文件?我可以从哪里得到这个文件
  • C:\Users\ABC\AppData\Roaming\npm-cache_logs\2020-10-22T06_34_20_827Z-debug.log
  • 在问题中更新
  • 试试这个:npm install preset@1.0.0

标签: typescript react-native npm


【解决方案1】:

请尝试删除 package-lock.json 并再次 npm install。

【讨论】:

  • 但我必须从那里安装软件包
  • 我不认为你明白我的意思。
  • ohk 那么为什么要删除 package-lock.json 呢?
  • 它保存了之前安装的包的版本。所以你需要删除这个版本来安装新更新的。
  • 所以如果我删除了这个文件,那么如何重新安装它
【解决方案2】:
  1. 您只需要先清除您的 npm 缓存,因为您可以在终端运行以下命令 - 这将清除您之前由 npm 生成的所有缓存
npm cache clean --force
  1. 删除 node_modules 文件夹和 package-lock.json

  2. 现在通过运行这个命令到你的项目根路径

    重新安装你的node_modules(packages)
npm install

【讨论】:

  • npm 错误!代码 ENOVERSIONS npm 错误!没有可用于预设的有效版本
【解决方案3】:

根据如下错误:

没有可用于预设的有效版本

npmjs中搜索preset包你会发现,npmjs

中没有任何名称为preset的包

https://www.npmjs.com/search?q=preset

如果你删除 package.json 中的 preset 依赖项,你可以完美安装

   "preset": "1.0.0",

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-02-27
    • 2021-08-05
    • 1970-01-01
    • 1970-01-01
    • 2022-01-20
    • 1970-01-01
    • 2022-07-26
    • 2018-02-26
    相关资源
    最近更新 更多