簡體   English   中英

為什么我在這個 repo 中收到 npm install 大量錯誤

[英]Why do I get npm install massive error in this repo

我想使用這個react-file-viewer ,但我無法讓它運行。 當我執行“npm install”時,會出現大量錯誤。 我是新手,請指教?

我的節點版本是 v16.9.1

這個項目很舊,並且是為舊的 Node 版本創建的,我認為它有很多錯誤,我不知道從哪里開始。 如果我將所有 package.json 依賴項更新到最新版本,您認為它可以工作嗎?

PS C:\Users\user\Downloads\react-file-viewer-master (1)\react-file-viewer-master> npm install
npm WARN deprecated babel-preset-es2015@6.24.1: 🙌  Thanks for using Babel: we recommend using babel-preset-env now: please read https://babeljs.io/env to update!
npm WARN deprecated flatten@1.0.3: flatten is deprecated in favor of utility frameworks such as lodash.
npm WARN deprecated kleur@2.0.2: Please upgrade to kleur@3 or migrate to 'ansi-colors' if you prefer the old syntax. Visit <https://github.com/lukeed/kleur/releases/tag/v3.0.0\> for migration path(s).
npm WARN deprecated request-promise-native@1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
npm WARN deprecated eslint-loader@1.9.0: This loader has been deprecated. Please use eslint-webpack-plugin
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
npm WARN deprecated browserslist@2.11.3: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated left-pad@1.3.0: use String.prototype.padStart()
npm WARN deprecated html-webpack-plugin@2.30.1: out of support
npm WARN deprecated sane@2.5.2: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.        
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated svgo@0.7.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
npm WARN deprecated core-js@2.6.12: core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
npm ERR! code 1
npm ERR! path C:\Users\user\Downloads\react-file-viewer-master (1)\react-file-viewer-master\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: C:\Program Files\nodejs\node.exe C:\Users\user\Downloads\react-file-viewer-master (1)\react-file-viewer-master\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   'C:\\Program Files\\nodejs\\node.exe',
npm ERR! gyp verb cli   'C:\\Users\\user\\Downloads\\react-file-viewer-master (1)\\react-file-viewer-master\\node_modules\\node-gyp\\bin\\node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@16.9.1 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (C:\Users\user\Downloads\react-file-viewer-master (1)\react-file-viewer-master\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (C:\Users\user\Downloads\react-file-viewer-master (1)\react-file-viewer-master\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (C:\Users\user\Downloads\react-file-viewer-master (1)\react-file-viewer-master\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at C:\Users\user\Downloads\react-file-viewer-master (1)\react-file-viewer-master\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at C:\Users\user\Downloads\react-file-viewer-master (1)\react-file-viewer-master\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at C:\Users\user\Downloads\react-file-viewer-master (1)\react-file-viewer-master\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb `which` failed  python2 Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (C:\Users\user\Downloads\react-file-viewer-master (1)\react-file-viewer-master\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (C:\Users\user\Downloads\react-file-viewer-master (1)\react-file-viewer-master\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (C:\Users\user\Downloads\react-file-viewer-master (1)\react-file-viewer-master\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at C:\Users\user\Downloads\react-file-viewer-master (1)\react-file-viewer-master\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at C:\Users\user\Downloads\react-file-viewer-master (1)\react-file-viewer-master\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at C:\Users\user\Downloads\react-file-viewer-master (1)\react-file-viewer-master\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21) {
npm ERR! gyp verb `which` failed   code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp verb check python checking for Python executable "python" in the PATH
npm ERR! gyp verb `which` succeeded python C:\Python39\python.EXE
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Command failed: C:\Python39\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack   File "<string>", line 1
npm ERR! gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack                       ^
npm ERR! gyp ERR! stack SyntaxError: invalid syntax
npm ERR! gyp ERR! stack
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:397:12)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:394:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1064:16)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm ERR! gyp ERR! System Windows_NT 10.0.19042
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\user\\Downloads\\react-file-viewer-master (1)\\react-file-viewer-master\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd C:\Users\user\Downloads\react-file-viewer-master (1)\react-file-viewer-master\node_modules\node-sass
npm ERR! gyp ERR! node -v v16.9.1
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\user\AppData\Local\npm-cache\_logs\2021-12-25T08_40_04_195Z-debug.log
PS C:\Users\user\Downloads\react-file-viewer-master (1)\react-file-viewer-master>

在此處輸入圖像描述

看起來像 Python 的問題。

你可以在下面運行並檢查它是否有幫助,

npm install express

否則,請在下面嘗試

刪除 node_modules 文件夾

以管理權限運行 npm install --global windows-build-tools。

使用 npm install 重新安裝節點模塊或 node-sass

突出顯示錯誤日志中的一些錯誤行

npm ERR! gyp verb checks python checking for Python executable "python2" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2

npm ERR! gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack                       ^
npm ERR! gyp ERR! stack SyntaxError: invalid syntax

這簡單的意思是,該過程正在尋找 Python v2.x 並且找不到。 因此,請繼續使用您計算機上的 Python v3.9。 但是,然后他們點擊了在 Python v3.x 中無效的print語句(但在 Python v2.x 中有效)

你可以做

  1. 安裝 Python v2.x(與 Python v3.x 並排安裝)。
  2. 更新node-sass (正如我在您的評論中看到的那樣,您已經這樣做了)。

正如您在錯誤中看到的那樣,在安裝node-sass期間運行node-gyp時發生了錯誤。 錯誤日志中還提到,您很可能沒有安裝 Python。

嘗試運行node-gyp rebuild

如果失敗,則表示設置不正確。 按照node-gyp文檔正確設置您的環境,然后重新運行npm install

另外,查看node-sass支持的 Node 版本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM