我在windows 10上安装了Node.js版本12.18.1和python版本3.8.1,当我在一个项目中运行npm安装时,我遇到了以下错误:
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Program Files (x86)\Python\Python\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 (child_process.js:303:12)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\x199377\\AppData\\Local\\Programs\\Git\\react-whiteapp\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\Users\x199377\AppData\Local\Programs\Git\react-whiteapp\node_modules\node-sass
gyp ERR! node -v v12.18.2
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
我认为PythonV3.x希望打印字符串包含在()
中。 您可以给出如下内容:
打印(“%s.%s.%s”%sys.version_info[:3])
这个问题是由于node-sassv14.40
引起的,它依赖于node-gypv3.8.0
,我将python从v3降级到v2以修复这个问题。