【发布时间】:2022-01-11 15:18:38
【问题描述】:
我正在尝试 npm install 在 Vue 项目中,即使我只是运行 vue create (name) 它给了我这个错误:
npm ERR! gyp verb check python checking for Python executable "c:\Python310\python.exe" in the PATH
npm ERR! gyp verb `which` succeeded c:\Python310\python.exe c:\Python310\python.exe
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Command failed: c:\Python310\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: Missing parentheses in call to 'print'. Did you mean print(...)?
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:390: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.19044
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Upwork\\contact_book\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd C:\Upwork\contact_book\node_modules\node-sass
npm ERR! gyp ERR! node -v v16.13.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
我在另一台电脑上试过,但它工作正常,我认为是因为我需要安装一些东西(因为电脑是新的)
【问题讨论】:
-
我假设
gyp是一个 Node 包(我不是 JS 人)。无论如何,如果是这样,维护者需要更新他们的安装脚本。print "blah blah blah"语法来自 Python 2,这是一个旧版本,已经失去支持超过 2 年,并且在此之前很久就被弃用了。正确的 Python 3 语法应该是print("blah blah blah"),因为print()现在是一个函数。 -
我看到
node-gyp现在使用的是 8.4.1 版,而您似乎使用的是 2018 年发布的 3.8.0 版。您肯定需要升级。 -
好的,谢谢你,我会尝试这些修复并让你知道@MattDMo
-
我试过
npm i -g node-gyp,但它仍然显示相同的错误node-gyp -v v3.8.0 -
嘿@MattDMo,我发现 Node 16 现在不支持它,所以我将 Node.js 降级到 v14.18.0 并且它有效,如果你没有告诉我,非常感谢关于版本我不会关注它
标签: python vue.js npm npm-install