Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
218 views
in Technique[技术] by (71.8m points)

node.js - Every time i try to install a new package i get gyp err syntax error

I was installing firebase, before this I tried installing yarn add react-router-dom, this same thing happened I had to create new project and copy all files again to new project , one thing I noticed was this happened after adding the project to github, before I added the project to the github repository, if i installed any packages, I didn't get any error,

$ yarn add firebase
yarn add v1.22.5
[1/4] Resolving packages...
warning node-sass > node-gyp > [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
[2/4] Fetching packages...
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > @testing-library/[email protected]" has unmet peer dependency "@testing-library/dom@>=7.21.4".
warning "react-scripts > @typescript-eslint/eslint-plugin > [email protected]" 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:UsersMuhammadDesktopReact projectsszone-shoppee-project
ode_modules
ode-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: C:UsersMuhammadDesktopReact projectsszone-shoppee-project
ode_modules
ode-sass
Output:
Building: C:Program Files
odejs
ode.exe C:UsersMuhammadDesktopReact projectsszone-shoppee-project
ode_modules
ode-gypin
ode-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 [email protected]
gyp info using [email protected] | 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:UsersMuhammadDesktopReact projectsszone-shoppee-project
ode_moduleswhichwhich.js:13:12)
gyp verb `which` failed     at F (C:UsersMuhammadDesktopReact projectsszone-shoppee-project
ode_moduleswhichwhich.js:68:19)
gyp verb `which` failed     at E (C:UsersMuhammadDesktopReact projectsszone-shoppee-project
ode_moduleswhichwhich.js:80:29)
gyp verb `which` failed     at C:UsersMuhammadDesktopReact projectsszone-shoppee-project
ode_moduleswhichwhich.js:89:16
gyp verb `which` failed     at C:UsersMuhammadDesktopReact projectsszone-shoppee-project
ode_modulesisexeindex.js:42:5
gyp verb `which` failed     at C:UsersMuhammadDesktopReact projectsszone-shoppee-project
ode_modulesisexewindows.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:UsersMuhammadDesktopReact projectsszone-shoppee-project
ode_moduleswhichwhich.js:13:12)
gyp verb `which` failed     at F (C:UsersMuhammadDesktopReact projectsszone-shoppee-project
ode_moduleswhichwhich.js:68:19)
gyp verb `which` failed     at E (C:UsersMuhammadDesktopReact projectsszone-shoppee-project
ode_moduleswhichwhich.js:80:29)
gyp verb `which` failed     at C:UsersMuhammadDesktopReact projectsszone-shoppee-project
ode_moduleswhichwhich.js:89:16
gyp verb `which` failed     at C:UsersMuhammadDesktopReact projectsszone-shoppee-project
ode_modulesisexeindex.js:42:5
gyp verb `which` failed     at C:UsersMuhammadDesktopReact projectsszone-shoppee-project
ode_modulesisexewindows.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:Python38python.EXE
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:Python38python.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:UsersMuhammadDesktopReact projectsszone-shoppee-project
ode_modules
ode-sass
gyp ERR! node -v v15.5.1
gyp ERR! node-gyp -v v3.8.0
question from:https://stackoverflow.com/questions/65844388/every-time-i-try-to-install-a-new-package-i-get-gyp-err-syntax-error

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can do either of these two things.

  1. Downgrade Python to 2.x.

  2. Install the packages using npm install --ignore-scripts

NOTE: This will cause npm to stop running scripts defined in the package.json


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...