栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Nodejs node-gyp运行错误

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Nodejs node-gyp运行错误

Nodejs node-gyp运行错误
  1. 现象
    控制台错误信息:
    npm ERR! path D:WorkSpacesc-new-uinode_modulesnode-sass
    npm ERR! command failed
    npm ERR! command C:Windowssystem32cmd.exe /d /s /c node-gyp rebuild
    npm ERR! gyp info it worked if it ends with ok
    npm ERR! gyp info using node-gyp@3.8.0
    npm ERR! gyp info using node@16.10.0 | win32 | x64
    npm ERR! gyp ERR! configure error
    npm ERR! gyp ERR! stack Error: Command failed: C:Python39python.EXE -c import sys; print “%s.%s.%s” % sys.version_info[:3];
    npm ERR! gyp ERR! stack File “”, 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:390:28)
    npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1064:16)
    npm ERR! gyp ERR! stack at Socket. (node:internal/child_process:450:11)
    npm ERR! gyp ERR! stack at Socket.emit (node:events:390:28)
    npm ERR! gyp ERR! stack at Pipe. (node:net:672:12)
    npm ERR! gyp ERR! System Windows_NT 10.0.19041
    npm ERR! gyp ERR! command “C:nodejsnode.exe” “D:WorkSpacesc-new-uinode_modulesnode-gypbinnode-gyp.js” “rebuild”
    npm ERR! gyp ERR! cwd D:WorkSpacesc-new-uinode_modulesnode-sass
    npm ERR! gyp ERR! node -v v16.10.0
    npm ERR! gyp ERR! node-gyp -v v3.8.0
    npm ERR! gyp ERR! not ok
    运行截图

  2. 解决
    思路
    将运行环境python版本由3.9.7降到2.7.x
    实践
    卸载最新python3.9.x
    安装python2.7.x
    重新安装node-sass
    重新安装node-gyp

  3. 分析
    本人下载最新的nodejs(v16.10.0),内部插件node-gyp的版本是8.2.0;导致该问题的根本原因是因为node-gyp不支持默认最新的python,导致在编译的时候因获取python版本异常,最后编译终止!
    关键信息截图

    报错命令在python2.7.18下运行成功截图

    初始版本截图:

    降级版本截图:

    运行成功截图

  4. 总结
    如果还是有问题,直接降级nodejs版本吧!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/280584.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号