NodeJS npm安装在git操作中失败,但在本地工作

56lgkhnf  于 2023-01-04  发布在  Node.js
关注(0)|答案(1)|浏览(214)

Git操作npm install '在我的计算机上运行时失败。这是我的操作

name: Check for lint/build errors

on:
  pull_request:
    branches:
      - '**'

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v2
      with:
        submodules: recursive
        token: ${{ secrets.SEMANTIC_RELEASE_PAT }}

    - uses: actions/setup-node@v2
      with:
        node-version: 16
        registry-url: https://registry.npmjs.org/

    - name: Set NPM_TOKEN
      run: echo "NPM_TOKEN=${{ secrets.NPM_TOKEN }}" >> $GITHUB_ENV

    - name: npm install, lint
      run: |
        npm install
        npm run lint

在我的计算机中,我使用node版本v16.3.0
Ps:在我的本地机器上,我已经删除了package-lock.json,它仍然工作正常,下面是确切的错误

npm ERR! While resolving: @react-native-async-storage/async-storage@1.15.9
npm ERR! Found: react-native@0.68.2
npm ERR! node_modules/react-native
npm ERR!   react-native@"0.68.2" from the root project
npm ERR!   peer react-native@">=0.64.0-rc.0 || 0.0.0-*" from @react-native-community/cli@5.0.1
npm ERR!   node_modules/@react-native-community/cli
npm ERR!     dev @react-native-community/cli@"^5.0.1" from the root project
npm ERR!   11 more (react-native-actions-sheet, react-native-check-box, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react-native@"^0.0.0-0 || ^0.60.6 || ^0.61.5 || ^0.62.2 || ^0.63.2 || ^0.64.0 || ^0.65.0 || ^0.66.0 || 1000.0.0" from @react-native-async-storage/async-storage@1.15.9
npm ERR! node_modules/@react-native-async-storage/async-storage
npm ERR!   @react-native-async-storage/async-storage@"^1.15.4" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: react-native@0.66.5
npm ERR! node_modules/react-native
npm ERR!   peer react-native@"^0.0.0-0 || ^0.60.6 || ^0.61.5 || ^0.62.2 || ^0.63.2 || ^0.64.0 || ^0.65.0 || ^0.66.0 || 1000.0.0" from @react-native-async-storage/async-storage@1.15.9
npm ERR!   node_modules/@react-native-async-storage/async-storage
npm ERR!     @react-native-async-storage/async-storage@"^1.15.4" 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 /home/runner/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2022-12-30T10_36_18_687Z-debug-0.log

你知道为什么会这样吗?我该怎么补救。

2q5ifsrm

2q5ifsrm1#

你应该把package-lock.json添加到你的git仓库中。
第二个不推荐且可能导致难以重现行为的选项是

npm i --force

您可以在此处检查强制部署和传统对等部署之间的差异:
npm: When to use --force and --legacy-peer-deps
要在本地报告此问题,您不仅必须删除package-lock.json,还必须删除node_modules

相关问题