NodeJS 在npm install `npm WARN tar zlib上获取错误:不正确的数据检查`

ctehm74n  于 2023-08-04  发布在  Node.js
关注(0)|答案(1)|浏览(376)

**发生了什么?**当我从项目目录中运行npm install时,我看到以下消息:

npm WARN tar zlib: incorrect data check
npm WARN tarball cached data for acorn@https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz (sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==) seems to be corrupted. Refreshing cache.
npm WARN tar zlib: incorrect data check
npm WARN tarball cached data for regexpp@https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz (sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==) seems to be corrupted. Refreshing cache.
npm WARN deprecated flatten@1.0.3: flatten is deprecated in favor of utility frameworks such as lodash.
npm WARN tarball tarball data for regexpp@https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz (sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==) seems to be corrupted. Trying again.
npm WARN tarball tarball data for acorn@https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz (sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==) seems to be corrupted. Trying again.
npm WARN tar TAR_ENTRY_INVALID checksum failure
npm WARN tar zlib: incorrect data check
npm WARN tarball tarball data for @angular/compiler@https://registry.npmjs.org/@angular/compiler/-/compiler-8.2.14.tgz (sha512-ABZO4E7eeFA1QyJ2trDezxeQM5ZFa1dXw1Mpl/+1vuXDKNjJgNyWYwKp/NwRkLmrsuV0yv4UDCDe4kJOGbPKnw==) seems to be corrupted. Trying again.
npm WARN tarball tarball data for @angular/compiler@https://registry.npmjs.org/@angular/compiler/-/compiler-8.2.14.tgz (sha512-ABZO4E7eeFA1QyJ2trDezxeQM5ZFa1dXw1Mpl/+1vuXDKNjJgNyWYwKp/NwRkLmrsuV0yv4UDCDe4kJOGbPKnw==) seems to be corrupted. Trying again.
npm ERR! code ENOENT
npm ERR! syscall stat
npm ERR! path /Users/USERNAME/.npm/_cacache/content-v2/sha512/00/16/4ee04ede785035432276b6b0decf17903396456b5757c3532997ffb5bee5c328d8c980dc966302a9fcdc1190b9abb2e574cafe140c20dee2424e19b3ca9f
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, stat '/Users/USERNAME/.npm/_cacache/content-v2/sha512/00/16/4ee04ede785035432276b6b0decf17903396456b5757c3532997ffb5bee5c328d8c980dc966302a9fcdc1190b9abb2e574cafe140c20dee2424e19b3ca9f'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/USERNAME/.npm/_logs/2023-01-31T17_52_09_696Z-debug-0.log

字符串
这是我的包。json:

{
  "name": "my-api",
  "version": "2.0.0",
  "description": "",
  "scripts": {
    "dev": "docker-compose up -d; aws-vault exec nonprod -- sam local start-api -t sam-update.yml --docker-network sam-local --env-vars env.json",
    "build": "bash -c './bin/build.sh'",
    "deploy": "bash -c './bin/deploy.sh $npm_package_name $0 $1'",
    "invoke": "sam local invoke -t sam-update.yml --docker-network sam-local --env-vars env.json",
    "lint": "prettier-standard --format --lint './src/**/*.{js,jsx,ts,tsx,css,scss}'",
    "lint-ci": "prettier-standard --lint './src/**/*.{js,jsx,ts,tsx,css,scss}'",
    "meta": "bash -c './bin/meta.sh $npm_package_name $0 $1'",
    "package": "bash -c './bin/package.sh $npm_package_name $0 $1'",
    "postinstall": "pip install -r requirements-dev.txt && husky install",
    "setup": "bash -c './bin/setup.sh $npm_package_name $0 $1'",
    "test": "NODE_ENV=test jest -u",
    "test:coverage": "mkdir -p ./src/coverage ; NODE_ENV=test jest --coverage | tee ./src/coverage/coverage.txt",
    "test-ci": "NODE_ENV=test jest --silent",
    "update": "bash -c './bin/update.sh $npm_package_name $0 $1'"
  },
  "license": "CC BY-SA",
  "keywords": [],
  "devDependencies": {
    "husky": "^5.2.0",
    "jest": "^29.3.1",
    "prettier-standard": "^16.4.1"
  },
  "overrides": {
    "find-parent-dir": "0.3.1"
  },
  "eslintConfig": {
    "env": {
      "jest": true,
      "node": true,
      "es6": true
    },
    "parserOptions": {
      "sourceType": "module",
      "ecmaVersion": 2020
    },
    "ignorePatterns": [
      "**/node_modules/**",
      "**/*.spec.js"
    ]
  },
  "jest": {
    "coverageReporters": [
      "json-summary",
      "text"
    ],
    "collectCoverageFrom": [
      "<rootDir>/**/*.js"
    ],
    "setupFiles": [
      "<rootDir>/../.jest/setEnvVars.js"
    ],
    "modulePaths": [
      "<rootDir>/layers/AuthorizerLayer/nodejs/node_modules",
      "<rootDir>/layers/PlagiarismLayer/nodejs/node_modules",
      "<rootDir>/layers/WebsocketLayer/nodejs/node_modules"
    ],
    "moduleNameMapper": {
      "/opt/(\\w*)": "<rootDir>/../src/layers/$1/$1.js",
      "aws-sdk": "<rootDir>/../__mocks__/aws-sdk",
      "aws-xray-sdk": "<rootDir>/../__mocks__/aws-xray-sdk"
    },
    "rootDir": "./src",
    "testEnvironment": "node"
  },
  "prettier": {
    "semi": true,
    "trailingComma": "es5",
    "arrowParens": "avoid",
    "singleQuote": true
  }
}

**我试图修复的问题:**我做的第一件事是用npm install --cache=/tmp/cache/设置一个临时缓存位置,但这并没有解决这个问题。在那之后,我只是开始抛出解决方案,希望有些东西能起作用,而不是完全理解发生了什么。还应该注意的是,我做的第一件事是删除repo中的所有node_modules和package-lock.json文件。

  • 我跑了npm cache clean
  • 从我的本地计算机中删除了存储库并重新克隆
  • 卸载节点版本(通过NVM)并重新安装
  • 完全卸载node和nvm,删除mac上的.node.npm和所有其他*node*文件夹,然后重新启动并重新安装nvm和node

在所有这些之后,仍然得到相同的错误消息。如果在我的机器上创建一个新的目录,初始化一个package.json,然后运行npm install --save-dev husky prettier-standard jest,它就可以正常安装了。让我相信这是一个问题的回购,但是,没有其他人在我的团队是遇到这个问题与相同的回购在他们的机器上。所以不知道发生了什么事或如何解决它。

wnvonmuf

wnvonmuf1#

我也有类似的问题。在访问完整的日志后,我发现:csvtojson@^2.0.10 zlib出现愚蠢的fetchPackageMetaData错误:数据检查不正确。似乎是de csvtojson库导致了这个错误

相关问题