M1芯片 Macbook Air 本地 Docker 前端构建镜像报错
gyp verb find Python Python is not set from command line or npm configuration
一开始本地是默认python 2.7,查说让更新到 3版本,我更新到了 3.10。然而仍然失败。
下载安装,然后配置
vim ~/.bash_profile
添加如下内容:
alias python=“/usr/local/bin/python3.10”
然而并不好用
又查发现要更新node 版本到 15,当前是 14.8.1遂更新node 到 15.4。
仍然失败.
放弃!
经不懈努力,发现
不支持arm
https://github.com/sass/node-sass/releases/download/v4.14.1/linux-arm64-83_binding.node
这才是错误的根源。
好了把node-sass 改成 sass 就行了
#11 91.68 npm ERR! gyp info it worked if it ends with ok
#11 91.68 npm ERR! gyp info using node-gyp@8.4.1
#11 91.68 npm ERR! gyp info using node@16.14.2 | linux | arm64
#11 91.68 npm ERR! gyp ERR! find Python
#11 91.68 npm ERR! gyp ERR! find Python Python is not set from command line or npm configuration
#11 91.68 npm ERR! gyp ERR! find Python Python is not set from environment variable PYTHON
#11 91.68 npm ERR! gyp ERR! find Python checking if "python3" can be used
#11 91.68 npm ERR! gyp ERR! find Python - "python3" is not in PATH or produced an error
#11 91.68 npm ERR! gyp ERR! find Python checking if "python" can be used
#11 91.68 npm ERR! gyp ERR! find Python - "python" is not in PATH or produced an error
#11 91.68 npm ERR! gyp ERR! find Python
#11 91.68 npm ERR! gyp ERR! find Python **********************************************************
#11 91.68 npm ERR! gyp ERR! find Python You need to install the latest version of Python.
#11 91.68 npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
#11 91.68 npm ERR! gyp ERR! find Python you can try one of the following options:
#11 91.68 npm ERR! gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
#11 91.68 npm ERR! gyp ERR! find Python (accepted by both node-gyp and npm)
#11 91.68 npm ERR! gyp ERR! find Python - Set the environment variable PYTHON
#11 91.68 npm ERR! gyp ERR! find Python - Set the npm configuration variable python:
#11 91.68 npm ERR! gyp ERR! find Python npm config set python "/path/to/pythonexecutable"
#11 91.68 npm ERR! gyp ERR! find Python For more information consult the documentation at:
#11 91.68 npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
#11 91.68 npm ERR! gyp ERR! find Python **********************************************************
#11 91.68 npm ERR! gyp ERR! find Python
#11 91.68 npm ERR! gyp ERR! configure error
#11 91.68 npm ERR! gyp ERR! stack Error: Could not find any Python installation to use
#11 91.68 npm ERR! gyp ERR! stack at PythonFinder.fail (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:330:47)
#11 91.68 npm ERR! gyp ERR! stack at PythonFinder.runChecks (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:159:21)
#11 91.68 npm ERR! gyp ERR! stack at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:202:16)
#11 91.68 npm ERR! gyp ERR! stack at PythonFinder.execFileCallback (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:294:16)
#11 91.68 npm ERR! gyp ERR! stack at exithandler (node:child_process:406:5)
#11 91.68 npm ERR! gyp ERR! stack at ChildProcess.errorhandler (node:child_process:418:5)
#11 91.68 npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:526:28)
#11 91.68 npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
#11 91.68 npm ERR! gyp ERR! stack at onErrorNT (node:internal/child_process:478:16)
#11 91.68 npm ERR! gyp ERR! stack at processTicksAndRejections (node:internal/process/task_queues:83:21)
#11 91.68 npm ERR! gyp ERR! System Linux 5.10.76-linuxkit
#11 91.68 npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
#11 91.68 npm ERR! gyp ERR! cwd /app/node_modules/deasync
#11 91.68 npm ERR! gyp ERR! node -v v16.14.2
#11 91.68 npm ERR! gyp ERR! node-gyp -v v8.4.1
#11 91.68 npm ERR! gyp ERR! not ok
#11 91.68 npm ERR! Build failed
#11 91.68
#11 91.68 npm ERR! A complete log of this run can be found in:
#11 91.68 npm ERR! /root/.npm/_logs/2022-04-10T03_34_23_844Z-debug-0.log
------
executor failed running [/bin/sh -c npm install && npm run build:${MODE}]: exit code: 1
在dockerfile
npm install
前添加环境变量安装就可以了
RUN apk add g++ make python
RUN npm install \
&& npm run build:${MODE}
版权声明:本文为du_peiduo原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。