node npm错误代码Z_DATA_ERROR errno -3 zlib:错误数据检查

xzlaal3s  于 2023-06-29  发布在  Node.js
关注(0)|答案(1)|浏览(1858)

我试图使用tsc运行我的typescript项目,但我得到这个错误:

  1. Found 181 errors in 4 files.
  2. Errors Files
  3. 1 node_modules/@types/eslint-scope/node_modules/@types/eslint/helpers.d.ts:1
  4. 1 node_modules/@types/eslint/helpers.d.ts:1
  5. 176 node_modules/@types/react-dom/node_modules/@types/react/index.d.ts:3089
  6. 3 node_modules/@types/react/index.d.ts:2970

我试着像这样更新其中一个模块,但它不起作用:

  1. npm install --save @types/eslint-scope
  2. npm ERR! code ERESOLVE
  3. npm ERR! ERESOLVE unable to resolve dependency tree
  4. npm ERR!
  5. npm ERR! While resolving: project@1.4.0
  6. npm ERR! Found: react@18.2.0
  7. npm ERR! node_modules/react
  8. npm ERR! react@"18.2.0" from the root project
  9. npm ERR!
  10. npm ERR! Could not resolve dependency:
  11. npm ERR! peer react@"16.13.1" from @design-systems/theme@3.7.0
  12. npm ERR! node_modules/@design-systems/theme
  13. npm ERR! peer @design-systems/theme@"^3.0.0" from @appfabric/providers@2.2.46
  14. npm ERR! node_modules/@appfabric/providers
  15. npm ERR! @appfabric/providers@"2.2.46" from the root project
  16. npm ERR!
  17. npm ERR! Fix the upstream dependency conflict, or retry
  18. npm ERR! this command with --force or --legacy-peer-deps
  19. npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
  20. npm ERR!
  21. npm ERR!
  22. npm ERR! For a full report see:
  23. npm ERR! /Users/abell5/.npm/_logs/2023-06-23T21_41_25_807Z-eresolve-report.txt

这也不起作用:

  1. % npm i npm@latest
  2. ...
  3. npm ERR! code Z_DATA_ERROR
  4. npm ERR! errno -3
  5. npm ERR! zlib: incorrect data check

有什么想法吗?

xwmevbvl

xwmevbvl1#

在最新版本的node中显然有一个bug,请参阅Zlib error when attempting to run npm install or yarn
你需要做降级纱和重新安装 typescript
确保安装了节点版本管理器(nvm),然后降级到节点14.17

  1. nvm install 14.17
  2. nvm alias default 14.17
  3. npm install typescript --save-dev
  4. tsc

在经历了类似的错误后为我工作:)
然后,确保您的JS项目成功构建,并且只编辑tsconfig.json文件,如https://www.typescriptlang.org/docs/handbook/migrating-from-javascript.html中所示,然后运行tsc。应该工作。

相关问题