yarn install 安装报python错
yarn install 安装报python错
执行yarn --cwd /root/workspace/agent-pc-html install报错,python版本不对,最后发现是nodejs的问题
[2022-09-08 16:38:35] gyp verb find Python Python is not set from command line or npm configuration [2022-09-08 16:38:35] gyp verb find Python Python is not set from environment variable PYTHON [2022-09-08 16:38:35] gyp verb find Python checking if "python3" can be used [2022-09-08 16:38:35] gyp verb find Python - executing "python3" to get executable path [2022-09-08 16:38:35] gyp verb find Python - executable path is "/usr/bin/python3" [2022-09-08 16:38:35] gyp verb find Python - executing "/usr/bin/python3" to get version [2022-09-08 16:38:35] gyp verb find Python - version is "3.5.2" [2022-09-08 16:38:35] gyp verb find Python - version is 3.5.2 - should be >=3.6.0 [2022-09-08 16:38:35] gyp verb find Python - THIS VERSION OF PYTHON IS NOT SUPPORTED [2022-09-08 16:38:35] gyp verb find Python checking if "python" can be used [2022-09-08 16:38:35] gyp verb find Python - executing "python" to get executable path [2022-09-08 16:38:35] gyp verb find Python - executable path is "/usr/bin/python" [2022-09-08 16:38:35] gyp verb find Python - executing "/usr/bin/python" to get version [2022-09-08 16:38:35] gyp verb find Python - version is "2.7.12" [2022-09-08 16:38:35] gyp verb find Python - version is 2.7.12 - should be >=3.6.0 [2022-09-08 16:38:35] gyp verb find Python - THIS VERSION OF PYTHON IS NOT SUPPORTED [2022-09-08 16:38:35] gyp ERR! find Python [2022-09-08 16:38:35] gyp ERR! find Python Python is not set from command line or npm configuration [2022-09-08 16:38:35] gyp ERR! find Python Python is not set from environment variable PYTHON [2022-09-08 16:38:35] gyp ERR! find Python checking if "python3" can be used [2022-09-08 16:38:35] gyp ERR! find Python - executable path is "/usr/bin/python3" [2022-09-08 16:38:35] gyp ERR! find Python - version is "3.5.2" [2022-09-08 16:38:35] gyp ERR! find Python - version is 3.5.2 - should be >=3.6.0 [2022-09-08 16:38:35] gyp ERR! find Python - THIS VERSION OF PYTHON IS NOT SUPPORTED [2022-09-08 16:38:35] gyp ERR! find Python checking if "python" can be used [2022-09-08 16:38:35] gyp ERR! find Python - executable path is "/usr/bin/python" [2022-09-08 16:38:35] gyp ERR! find Python - version is "2.7.12" [2022-09-08 16:38:35] gyp ERR! find Python - version is 2.7.12 - should be >=3.6.0 [2022-09-08 16:38:35] gyp ERR! find Python - THIS VERSION OF PYTHON IS NOT SUPPORTED [2022-09-08 16:38:35] gyp ERR! find Python [2022-09-08 16:38:35] gyp ERR! find Python ********************************************************** [2022-09-08 16:38:35] gyp ERR! find Python You need to install the latest version of Python. [2022-09-08 16:38:35] gyp ERR! find Python Node-gyp should be able to find and use Python. If not, [2022-09-08 16:38:35] gyp ERR! find Python you can try one of the following options: [2022-09-08 16:38:35] gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable" [2022-09-08 16:38:35] gyp ERR! find Python (accepted by both node-gyp and npm) [2022-09-08 16:38:35] gyp ERR! find Python - Set the environment variable PYTHON [2022-09-08 16:38:35] gyp ERR! find Python - Set the npm configuration variable python: [2022-09-08 16:38:35] gyp ERR! find Python npm config set python "/path/to/pythonexecutable" [2022-09-08 16:38:35] gyp ERR! find Python For more information consult the documentation at: [2022-09-08 16:38:35] gyp ERR! find Python https://github.com/nodejs/node-gyp#installation [2022-09-08 16:38:35] gyp ERR! find Python ********************************************************** [2022-09-08 16:38:35] gyp ERR! find Python [2022-09-08 16:38:35] gyp ERR! configure error [2022-09-08 16:38:35] gyp ERR! stack Error: Could not find any Python installation to use [2022-09-08 16:38:35] gyp ERR! stack at PythonFinder.fail (/******/workspace/node_modules/node-gyp/lib/find-python.js:330:47) [2022-09-08 16:38:35] gyp ERR! stack at PythonFinder.runChecks (/******/workspace/node_modules/node-gyp/lib/find-python.js:159:21) [2022-09-08 16:38:35] gyp ERR! stack at PythonFinder.<anonymous> (/******/workspace/node_modules/node-gyp/lib/find-python.js:266:16) [2022-09-08 16:38:35] gyp ERR! stack at PythonFinder.execFileCallback (/******/workspace/node_modules/node-gyp/lib/find-python.js:297:7) [2022-09-08 16:38:35] gyp ERR! stack at ChildProcess.exithandler (child_process.js:374:7) [2022-09-08 16:38:35] gyp ERR! stack at ChildProcess.emit (events.js:400:28) [2022-09-08 16:38:35] gyp ERR! stack at maybeClose (internal/child_process.js:1088:16) [2022-09-08 16:38:35] gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:296:5) [2022-09-08 16:38:35] gyp ERR! System Linux 5.11.0-051100-generic [2022-09-08 16:38:35] gyp ERR! command "/usr/bin/node" "/******/workspace/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library=" [2022-09-08 16:38:35] gyp ERR! cwd /******/workspace/node_modules/node-sass [2022-09-08 16:38:35] gyp ERR! node -v v14.20.0 [2022-09-08 16:38:35] gyp ERR! node-gyp -v v9.1.0 [2022-09-08 16:38:35] gyp ERR! not ok [2022-09-08 16:38:35] Build failed with error code: 1 [2022-09-08 16:38:35] npm WARN enoent ENOENT: no such file or directory, open '/******/workspace/package.json' [2022-09-08 16:38:35] npm WARN workspace No description [2022-09-08 16:38:35] npm WARN workspace No repository field. [2022-09-08 16:38:36] npm WARN workspace No README data [2022-09-08 16:38:36] npm WARN workspace No license field. [2022-09-08 16:38:36] [2022-09-08 16:38:36] npm ERR! code ELIFECYCLE [2022-09-08 16:38:36] npm ERR! errno 1 [2022-09-08 16:38:36] npm ERR! node-sass@7.0.2 postinstall: `node scripts/build.js` [2022-09-08 16:38:36] npm ERR! Exit status 1 [2022-09-08 16:38:36] npm ERR! [2022-09-08 16:38:36] npm ERR! Failed at the node-sass@7.0.2 postinstall script. [2022-09-08 16:38:36] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
解决
主要原因是: nodejs源站、nodejs和node-saas,并非日志抛出的Python版本的问题
#配置如下无果后清除缓存和项目缓存,重新拉取nodejs恢复,注释后正常yarn install
npm i --save node-sass
npm config set pytyon python3.7
yarn --cwd /root/workspace/agent-pc-html install