基于 React.js 的原生项目无法安装 Node 模块

问题描述 投票:0回答:1

运行 npm install 时出现错误,我想使用 React Native 运行现有的 React 项目,这两个项目合并为一个。

我已经安装了 nvm 以使用 npm 更改节点版本 error image node verison and npm version

npm WARN deprecated @types/[email protected]: This is a stub types definition. pusher-js provides its own type definitions, so you do not need this installed.
npm WARN deprecated @types/[email protected]: This is a stub types definition. concurrently provides its own type definitions, so you do not need this installed.
npm WARN deprecated [email protected]: dommatrix is no longer maintained. Please use @thednp/dommatrix.
npm WARN deprecated [email protected]: support for ECMAScript is superseded by `uglify-js` as of v3.13.0
npm ERR! code 1
npm ERR! path D:\Brijesh\react js\HG\Expensify\App\node_modules\shellcheck
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c ./install.sh
npm ERR! '.' is not recognized as an internal or external command,
npm ERR! operable program or batch file.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\brije\AppData\Local\npm-cache\_logs\2023-09-11T06_29_30_567Z-debug-0.log

打包 json 如下

{
  "name": "new.expensify",
  "version": "1.3.66-3",
  "author": "Expensify, Inc.",
  "homepage": "https://new.expensify.com",
  "description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
  "license": "MIT",
  "private": true,
  "scripts": {
    "configure-mapbox": "scripts/setup-mapbox-sdk-walkthrough.sh",
    "postinstall": "scripts/postInstall.sh",
    "clean": "npx react-native clean-project-auto",
    "android": "scripts/set-pusher-suffix.sh && npx react-native run-android --variant=developmentDebug --appId=com.expensify.chat.dev",
    "ios": "scripts/set-pusher-suffix.sh && npx react-native run-ios --configuration=\"Debug Development\" --scheme=\"New Expensify Dev\"",
    "pod-install": "cd ios && bundle exec pod install",
    "ipad": "concurrently \"npx react-native run-ios --simulator=\\\"iPad Pro (12.9-inch) (6th generation)\\\" --configuration=\\\"Debug Development\\\" --scheme=\\\"New Expensify Dev\\\"\"",
    "ipad-sm": "concurrently \"npx react-native run-ios --simulator=\\\"iPad Pro (11-inch) (4th generation)\\\" --configuration=\\\"Debug Development\\\" --scheme=\\\"New Expensify Dev\\\"\"",
    "start": "npx react-native start",
    "web": "scripts/set-pusher-suffix.sh && concurrently npm:web-proxy npm:web-server",
    "web-proxy": "node web/proxy.js",
    "web-server": "webpack-dev-server --open --config config/webpack/webpack.dev.js",
    "build": "webpack --config config/webpack/webpack.common.js --env envFile=.env.production",
    "build-staging": "webpack --config config/webpack/webpack.common.js --env envFile=.env.staging",
    "build-adhoc": "webpack --config config/webpack/webpack.common.js --env envFile=.env.adhoc",
    "desktop": "scripts/set-pusher-suffix.sh && node desktop/start.js",
    "desktop-build": "scripts/build-desktop.sh production",
    "desktop-build-staging": "scripts/build-desktop.sh staging",
    "createDocsRoutes": "node .github/scripts/createDocsRoutes.js",
    "desktop-build-adhoc": "scripts/build-desktop.sh adhoc",
    "ios-build": "fastlane ios build",
    "android-build": "fastlane android build",
    "android-build-e2e": "bundle exec fastlane android build_e2e",
    "test": "TZ=utc jest",
    "typecheck": "tsc",
    "lint": "eslint . --max-warnings=0 --cache --cache-location=node_modules/.cache/eslint",
    "lint-changed": "eslint --fix $(git diff --diff-filter=AM --name-only main -- \"*.js\" \"*.ts\" \"*.tsx\")",
    "lint-watch": "npx eslint-watch --watch --changed",
    "shellcheck": "./scripts/shellCheck.sh",
    "prettier": "prettier --write .",
    "prettier-watch": "onchange \"**/*.{js,ts,tsx}\" -- prettier --write --ignore-unknown {{changed}}",
    "print-version": "echo $npm_package_version",
    "storybook": "start-storybook -p 6006",
    "storybook-build": "ENV=production build-storybook -o dist/docs",
    "storybook-build-staging": "ENV=staging build-storybook -o dist/docs",
    "gh-actions-build": "./.github/scripts/buildActions.sh",
    "gh-actions-validate": "./.github/scripts/validateActionsAndWorkflows.sh",
    "analyze-packages": "ANALYZE_BUNDLE=true webpack --config config/webpack/webpack.common.js --env envFile=.env.production",
    "symbolicate:android": "npx metro-symbolicate android/app/build/generated/sourcemaps/react/release/index.android.bundle.map",
    "symbolicate:ios": "npx metro-symbolicate main.jsbundle.map",
    "test:e2e": "node tests/e2e/testRunner.js --development"
  },
  "dependencies": {
    "@expensify/react-native-web": "0.18.15",
    "@formatjs/intl-getcanonicallocales": "^2.2.0",
    "@formatjs/intl-listformat": "^7.2.2",
    "@formatjs/intl-locale": "^3.3.0",
    "@formatjs/intl-numberformat": "^8.5.0",
    "@formatjs/intl-pluralrules": "^5.2.2",
    "@gorhom/portal": "^1.0.14",
    "@invertase/react-native-apple-authentication": "^2.2.2",
    "@oguzhnatly/react-native-image-manipulator": "github:Expensify/react-native-image-manipulator#5cdae3d4455b03a04c57f50be3863e2fe6c92c52",
    "@onfido/react-native-sdk": "7.4.0",
    "@react-native-async-storage/async-storage": "^1.17.10",
    "@react-native-camera-roll/camera-roll": "5.4.0",
    "@react-native-community/clipboard": "^1.5.1",
    "@react-native-community/datetimepicker": "^3.5.2",
    "@react-native-community/netinfo": "^9.3.10",
    "@react-native-firebase/analytics": "^12.3.0",
    "@react-native-firebase/app": "^12.3.0",
    "@react-native-firebase/crashlytics": "^12.3.0",
    "@react-native-firebase/perf": "^12.3.0",
    "@react-native-google-signin/google-signin": "^10.0.1",
    "@react-native-picker/picker": "^2.4.3",
    "@react-navigation/material-top-tabs": "^6.6.3",
    "@react-navigation/native": "6.1.6",
    "@react-navigation/stack": "6.3.16",
    "@react-ng/bounds-observer": "^0.2.1",
    "@rnmapbox/maps": "^10.0.11",
    "@ua/react-native-airship": "^15.2.6",
    "awesome-phonenumber": "^5.4.0",
    "babel-plugin-transform-remove-console": "^6.9.4",
    "babel-polyfill": "^6.26.0",
    "canvas-size": "^1.2.6",
    "core-js": "^3.32.0",
    "date-fns": "^2.30.0",
    "date-fns-tz": "^2.0.0",
    "dom-serializer": "^0.2.2",
    "domhandler": "^4.3.0",
    "expensify-common": "git+ssh://[email protected]/Expensify/expensify-common.git#e63d06e239fe5b2f221e86eab71ae8a4e3b8bee3",
    "fbjs": "^3.0.2",
    "htmlparser2": "^7.2.0",
    "idb-keyval": "^6.2.1",
    "jest-when": "^3.5.2",
    "lodash": "4.17.21",
    "lottie-react-native": "^5.1.6",
    "mapbox-gl": "^2.15.0",
    "moment": "^2.29.4",
    "moment-timezone": "^0.5.31",
    "onfido-sdk-ui": "13.1.0",
    "patch-package": "^8.0.0",
    "process": "^0.11.10",
    "prop-types": "^15.7.2",
    "pusher-js": "7.4.0",
    "react": "18.2.0",
    "react-collapse": "^5.1.0",
    "react-content-loader": "^6.1.0",
    "react-dom": "18.1.0",
    "react-map-gl": "^7.1.3",
    "react-native": "0.72.3",
    "react-native-blob-util": "^0.17.3",
    "react-native-collapsible": "^1.6.0",
    "react-native-config": "^1.4.5",
    "react-native-dev-menu": "^4.1.1",
    "react-native-device-info": "^10.3.0",
    "react-native-document-picker": "^8.0.0",
    "react-native-fast-image": "^8.6.3",
    "react-native-fs": "^2.20.0",
    "react-native-gesture-handler": "2.12.0",
    "react-native-google-places-autocomplete": "git+https://github.com/Expensify/react-native-google-places-autocomplete.git#ee87343c3e827ff7818abc71b6bb04fcc1f120e0",
    "react-native-haptic-feedback": "^1.13.0",
    "react-native-image-pan-zoom": "^2.1.12",
    "react-native-image-picker": "^5.1.0",
    "react-native-image-size": "git+https://github.com/Expensify/react-native-image-size#8393b7e58df6ff65fd41f60aee8ece8822c91e2b",
    "react-native-key-command": "^1.0.1",
    "react-native-linear-gradient": "^2.8.1",
    "react-native-localize": "^2.2.6",
    "react-native-modal": "^13.0.0",
    "react-native-onyx": "1.0.72",
    "react-native-pager-view": "^6.2.0",
    "react-native-pdf": "^6.7.1",
    "react-native-performance": "^4.0.0",
    "react-native-permissions": "^3.0.1",
    "react-native-picker-select": "git+https://github.com/Expensify/react-native-picker-select.git#eae05855286dc699954415cc1d629bfd8e8e47e2",
    "react-native-plaid-link-sdk": "^10.0.0",
    "react-native-qrcode-svg": "^6.2.0",
    "react-native-quick-sqlite": "^8.0.0-beta.2",
    "react-native-reanimated": "3.4.0",
    "react-native-render-html": "6.3.1",
    "react-native-safe-area-context": "4.4.1",
    "react-native-screens": "3.21.0",
    "react-native-svg": "^13.9.0",
    "react-native-tab-view": "^3.5.2",
    "react-native-url-polyfill": "^2.0.0",
    "react-native-view-shot": "^3.6.0",
    "react-native-vision-camera": "^2.15.4",
    "react-native-web-linear-gradient": "^1.1.2",
    "react-native-web-lottie": "^1.4.4",
    "react-native-webview": "^11.17.2",
    "react-pdf": "^6.2.2",
    "react-plaid-link": "3.3.2",
    "react-web-config": "^1.0.0",
    "react-window": "^1.8.9",
    "save": "^2.4.0",
    "semver": "^7.5.2",
    "shim-keyboard-event-key": "^1.0.3",
    "underscore": "^1.13.1"
  },
  "devDependencies": {
    "@actions/core": "1.10.0",
    "@actions/github": "5.1.1",
    "@babel/core": "^7.20.0",
    "@babel/plugin-proposal-class-properties": "^7.12.1",
    "@babel/plugin-proposal-export-namespace-from": "^7.18.9",
    "@babel/preset-env": "^7.20.0",
    "@babel/preset-flow": "^7.12.13",
    "@babel/preset-react": "^7.10.4",
    "@babel/preset-typescript": "^7.21.5",
    "@babel/runtime": "^7.20.0",
    "@electron/notarize": "^1.2.3",
    "@jest/globals": "^29.5.0",
    "@octokit/core": "4.0.4",
    "@octokit/plugin-paginate-rest": "3.1.0",
    "@octokit/plugin-throttling": "4.1.0",
    "@react-native-community/eslint-config": "3.0.0",
    "@react-native/metro-config": "^0.72.9",
    "@react-navigation/devtools": "^6.0.10",
    "@storybook/addon-a11y": "^6.5.9",
    "@storybook/addon-essentials": "^7.0.0",
    "@storybook/addon-react-native-web": "0.0.19--canary.37.cb55428.0",
    "@storybook/addons": "^6.5.9",
    "@storybook/builder-webpack5": "^6.5.10",
    "@storybook/manager-webpack5": "^6.5.10",
    "@storybook/react": "^6.5.9",
    "@storybook/theming": "^6.5.9",
    "@svgr/webpack": "^6.0.0",
    "@testing-library/jest-native": "5.4.1",
    "@testing-library/react-native": "11.5.1",
    "@types/concurrently": "^7.0.0",
    "@types/jest": "^29.5.2",
    "@types/jest-when": "^3.5.2",
    "@types/js-yaml": "^4.0.5",
    "@types/lodash": "^4.14.195",
    "@types/mapbox-gl": "^2.7.13",
    "@types/mock-fs": "^4.13.1",
    "@types/pusher-js": "^5.1.0",
    "@types/react": "^18.2.12",
    "@types/react-collapse": "^5.0.1",
    "@types/react-dom": "^18.2.4",
    "@types/react-pdf": "^5.7.2",
    "@types/react-test-renderer": "^18.0.0",
    "@types/semver": "^7.5.0",
    "@types/setimmediate": "^1.0.2",
    "@types/underscore": "^1.11.5",
    "@typescript-eslint/eslint-plugin": "^6.2.1",
    "@typescript-eslint/parser": "^6.2.1",
    "@vercel/ncc": "^0.27.0",
    "@welldone-software/why-did-you-render": "7.0.1",
    "ajv-cli": "^5.0.0",
    "babel-eslint": "^10.1.0",
    "babel-jest": "29.4.1",
    "babel-loader": "^9.1.3",
    "babel-plugin-module-resolver": "^5.0.0",
    "babel-plugin-react-native-web": "^0.18.7",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "babel-plugin-transform-remove-console": "^6.9.4",
    "clean-webpack-plugin": "^3.0.0",
    "concurrently": "^5.3.0",
    "copy-webpack-plugin": "^6.4.1",
    "css-loader": "^6.7.2",
    "diff-so-fancy": "^1.3.0",
    "dotenv": "^16.0.3",
    "electron": "^25.4.0",
    "electron-builder": "24.5.0",
    "eslint": "^7.6.0",
    "eslint-config-airbnb-typescript": "^17.1.0",
    "eslint-config-expensify": "^2.0.38",
    "eslint-config-prettier": "^8.8.0",
    "eslint-plugin-jest": "^24.1.0",
    "eslint-plugin-jsdoc": "^46.2.6",
    "eslint-plugin-jsx-a11y": "^6.6.1",
    "eslint-plugin-react-hooks": "^4.6.0",
    "eslint-plugin-react-native-a11y": "^3.3.0",
    "eslint-plugin-storybook": "^0.5.13",
    "eslint-plugin-you-dont-need-lodash-underscore": "^6.12.0",
    "html-webpack-plugin": "^5.5.0",
    "jest": "29.4.1",
    "jest-circus": "29.4.1",
    "jest-cli": "29.4.1",
    "jest-environment-jsdom": "^29.4.1",
    "metro-react-native-babel-preset": "0.76.7",
    "mock-fs": "^4.13.0",
    "onchange": "^7.1.0",
    "portfinder": "^1.0.28",
    "prettier": "^2.8.8",
    "pusher-js-mock": "^0.3.3",
    "react-native-clean-project": "^4.0.0-alpha4.0",
    "react-native-flipper": "https://gitpkg.now.sh/facebook/flipper/react-native/react-native-flipper?9cacc9b59402550eae866e0e81e5f0c2f8203e6b",
    "react-native-performance-flipper-reporter": "^2.0.0",
    "react-native-svg-transformer": "^1.0.0",
    "react-test-renderer": "18.2.0",
    "reassure": "^0.9.0",
    "setimmediate": "^1.0.5",
    "shellcheck": "^1.1.0",
    "style-loader": "^2.0.0",
    "time-analytics-webpack-plugin": "^0.1.17",
    "type-fest": "^3.12.0",
    "typescript": "^5.1.6",
    "wait-port": "^0.2.9",
    "webpack": "^5.76.0",
    "webpack-bundle-analyzer": "^4.5.0",
    "webpack-cli": "^4.10.0",
    "webpack-dev-server": "^4.9.3",
    "webpack-font-preload-plugin": "^1.5.0",
    "webpack-merge": "^5.8.0"
  },
  "overrides": {
    "react-native": "$react-native"
  },
  "electronmon": {
    "patterns": [
      "!node_modules",
      "!node_modules/**/*",
      "!**/*.map",
      "!ios/**",
      "!android/**",
      "*.test.*",
      "*.spec.*"
    ]
  },
  "engines": {
    "node": "16.15.1",
    "npm": "8.11.0"
  }
}

我也尝试过清理 npm 缓存并删除包锁,然后 npm install 但仍然无法工作。

如果您有任何想法请告诉我。

我尝试使用Mac PC,使用brew和nvm,这工作正常,但在我的window笔记本电脑中,这不起作用,因为window不支持brew,所以我通过直接nvm进行节点版本更改。

我期待在 Window 中的退出项目中安装节点模块,这在 Mac PC 中运行良好。

谢谢你。

reactjs npm node-modules uglifyjs npm-package
1个回答
0
投票

您可以尝试执行以下一些其他步骤来排除故障并解决问题:

  1. 升级npm:您的项目指定npm版本8.11.0,这是一个相对较旧的版本。尝试将 npm 升级到更新版本,因为旧版本可能存在兼容性问题:

    npm install -g npm@latest

升级 npm 后,尝试再次运行 npm install。

  1. 以管理员身份运行:在某些情况下,权限问题可能会阻止 npm 在 Windows 上正常工作。尝试以管理员身份运行终端或命令提示符,然后运行 npm install。

  2. 防病毒/安全软件: Windows 计算机上的某些防病毒或安全软件可能会干扰安装过程。尝试在运行 npm install 时暂时禁用此类软件,看看是否可以解决问题。

  3. 使用 Yarn: 考虑使用 Yarn 作为 npm 的替代包管理器。众所周知,纱线在某些情况下更可靠。您可以全局安装 Yarn,然后使用它来安装依赖项:

    npm install -g 纱线 纱线安装

  4. 安装Windows-Build-Tools:如果您的项目与需要编译的本机代码(例如node-gyp)有依赖关系,您可能需要全局安装windows-build-tools包以确保编译工具可用:

    npm install -g windows-build-tools

© www.soinside.com 2019 - 2024. All rights reserved.