目 录CONTENT

文章目录

node编译not found: python2

xlong
2024-04-10 / 0 评论 / 0 点赞 / 5 阅读 / 2363 字 / 正在检测是否收录...

node编译not found: python2

node-sass编译器是通过C++实现的。在Node.js中,采用gyp构建工具进行构建c++代码,而gyp是基于python2开发的,且不支持python3

error node_modules/node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments: 
Directory: /home/jenkins/agent/workspace/ccreate-app/ccreate-app/node_modules/node-sass
Output:
...
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
...
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` failed Error: not found: python
...
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
...
gyp ERR! System Linux 4.18.0-80.11.2.el8_0.x86_64
gyp ERR! command "/usr/local/bin/node" "node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd node_modules/node-sass
gyp ERR! node -v v14.20.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
Build failed with error code: 1

解决方法:

1.查看是否缺少python2环境,安装pyton2环境。node-alpine容器中缺少python2环境。

2.修改node版本。

3.卸载node-sass,使用sass。(未验证)

0

评论区