每次我尝试安装新软件包时,我都会收到 gyp err 语法错误

时间:2021-01-22 11:35:09

标签: node.js reactjs npm sass yarnpkg

我正在安装firebase,在此之前我尝试安装yarn add react-router-dom,同样的事情发生了我不得不创建新项目并将所有文件再次复制到新项目,我注意到一件事 这是在将项目添加到github之后发生的,在我将项目添加到github存储库之前,如果我安装了任何包,我没有收到任何错误,

$ yarn add firebase
yarn add v1.22.5
[1/4] Resolving packages...
warning node-sass > node-gyp > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
[2/4] Fetching packages...
info fsevents@2.3.1: The platform "win32" is incompatible with this module.
info "fsevents@2.3.1" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.2.13: The platform "win32" is incompatible with this module.
info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@2.2.1: The platform "win32" is incompatible with this module.
info "fsevents@2.2.1" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@2.1.3: The platform "win32" is incompatible with this module.
info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > @testing-library/user-event@12.6.0" has unmet peer dependency "@testing-library/dom@>=7.21.4".
warning "react-scripts > @typescript-eslint/eslint-plugin > tsutils@3.17.1" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
[4/4] Building fresh packages...
[1/4] ⠄ node-sass
[-/4] ⠄ waiting...
[-/4] ⡀ waiting...
error C:\Users\Muhammad\Desktop\React projects\szone-shoppee-project\node_modules\node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: C:\Users\Muhammad\Desktop\React projects\szone-shoppee-project\node_modules\node-sass
Output:
Building: C:\Program Files\nodejs\node.exe C:\Users\Muhammad\Desktop\React projects\szone-shoppee-project\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli   'C:\\Users\\Muhammad\\Desktop\\React projects\\szone-shoppee-project\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library='
gyp verb cli ]
gyp info using node-gyp@3.8.0
gyp info using node@15.5.1 | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (C:\Users\Muhammad\Desktop\React projects\szone-shoppee-project\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\Users\Muhammad\Desktop\React projects\szone-shoppee-project\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\Users\Muhammad\Desktop\React projects\szone-shoppee-project\node_modules\which\which.js:80:29)
gyp verb `which` failed     at C:\Users\Muhammad\Desktop\React projects\szone-shoppee-project\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\Users\Muhammad\Desktop\React projects\szone-shoppee-project\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at C:\Users\Muhammad\Desktop\React projects\szone-shoppee-project\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:199:21)
gyp verb `which` failed  python2 Error: not found: python2
gyp verb `which` failed     at getNotFoundError (C:\Users\Muhammad\Desktop\React projects\szone-shoppee-project\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\Users\Muhammad\Desktop\React projects\szone-shoppee-project\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\Users\Muhammad\Desktop\React projects\szone-shoppee-project\node_modules\which\which.js:80:29)
gyp verb `which` failed     at C:\Users\Muhammad\Desktop\React projects\szone-shoppee-project\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\Users\Muhammad\Desktop\React projects\szone-shoppee-project\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at C:\Users\Muhammad\Desktop\React projects\szone-shoppee-project\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:199:21) {
gyp verb `which` failed   code: 'ENOENT'
gyp verb `which` failed }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python C:\Python38\python.EXE
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Python38\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                       ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack     at ChildProcess.exithandler (node:child_process:333:12)
gyp ERR! stack     at ChildProcess.emit (node:events:376:20)
gyp ERR! stack     at maybeClose (node:internal/child_process:1063:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:295:5)
gyp ERR! System Windows_NT 10.0.19042
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Muhammad\\Desktop\\React projects\\szone-shoppee-project\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\Users\Muhammad\Desktop\React projects\szone-shoppee-project\node_modules\node-sass
gyp ERR! node -v v15.5.1
gyp ERR! node-gyp -v v3.8.0

1 个答案:

答案 0 :(得分:0)

你可以做这两件事中的任何一件。

  1. 将 Python 降级到 2.x。

  2. 使用 npm install --ignore-scripts 安装软件包

注意:这将导致 npm 停止运行 package.json 中定义的脚本