【问题标题】:Can't run Gatsy project on UBUNTU无法在 UBUNTU 上运行 Gatsy 项目
【发布时间】:2021-05-09 14:02:34
【问题描述】:

我正在开发 Gatsby 项目并尝试在 UBUNTU 系统上运行它。尝试运行“npm install”时出现这样的错误。我从 git 存储库克隆了这个项目。在 Windows 上它工作正常,我可以用“gatsby develop”运行它,但在 UBUNTU 中它会抛出这样的错误...... 我该如何管理它?

npm ERR! code 1
npm ERR! path /home/grerin/Omertex/website/node_modules/sharp
npm ERR! command failed
npm ERR! command sh -c (node install/libvips && node install/dll-copy && prebuild-install --runtime=napi) || (node-gyp rebuild && node install/dll-copy)
npm ERR! info sharp Using cached /home/grerin/.npm/_libvips/libvips-8.9.1-linux-x64.tar.gz
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@15.8.0 | linux | x64
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
npm ERR! gyp ERR! stack     at PythonFinder.failNoPython (/home/grerin/Omertex/website/node_modules/node-gyp/lib/configure.js:484:19)
npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (/home/grerin/Omertex/website/node_modules/node-gyp/lib/configure.js:406:16)
npm ERR! gyp ERR! stack     at F (/home/grerin/Omertex/website/node_modules/which/which.js:68:16)
npm ERR! gyp ERR! stack     at E (/home/grerin/Omertex/website/node_modules/which/which.js:80:29)
npm ERR! gyp ERR! stack     at /home/grerin/Omertex/website/node_modules/which/which.js:89:16
npm ERR! gyp ERR! stack     at /home/grerin/Omertex/website/node_modules/isexe/index.js:42:5
npm ERR! gyp ERR! stack     at /home/grerin/Omertex/website/node_modules/isexe/mode.js:8:5
npm ERR! gyp ERR! stack     at FSReqCallback.oncomplete (node:fs:196:21)
npm ERR! gyp ERR! System Linux 5.8.0-41-generic
npm ERR! gyp ERR! command "/usr/bin/node" "/home/grerin/Omertex/website/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /home/grerin/Omertex/website/node_modules/sharp
npm ERR! gyp ERR! node -v v15.8.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/grerin/.npm/_logs/2021-02-05T07_45_41_662Z-debug.log

【问题讨论】:

    标签: node.js ubuntu npm gatsby npm-install


    【解决方案1】:

    关键是:

    npm ERR! gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
    

    Gatsby 和它们的一些依赖项和转换器(sharptransformer-sharp,主要用于图像处理)是用 Python 编码的,因此它是一个强制依赖项。

    在 Windows 中,由于windows-build-tools Python 依赖项是自动添加的,因此如果您从基于 Windows 的安装中克隆了 repo,则需要设置 Python。

    尝试运行:

    npm uninstall node-gyp -g
    npm config set python python2.7
    npm config set msvs_version 2015
    npm cache clean -f
    npm install
    

    或者,您可以在您的机器上尝试installing and setting Python,然后重试该过程

    【讨论】:

    • 感谢您回答 Ferran!我更新了 python 版本,但仍然有相同的错误 npm ERR!使用 node-gyp@3.8.0 npm 错误的 gyp 信息!使用 node@15.8.0 的 gyp 信息 | linux | x64 npm 错误!吉普错误!配置错误 npm ERR!吉普错误!堆栈错误:找不到 Python 可执行文件“python3.8.5”,您可以设置 PYTHON 环境变量。
    • 你安装node-gyp了吗?
    • 我正在尝试安装node-gyp,但总是失败..... grerin@Omertex:~$ sudo apt install node-gyp ...... 以下软件包未满足依赖项:node-gyp :依赖:libnode-dev 但不会安装 E:无法纠正问题,您持有损坏的包。
    • grerin@Omertex:~/Omertex/website$ node -v && npm -v v14.15.4 7.5.2 grerin@Omertex:~/Omertex/website$ node-gyp --version v7.1.2安装 node-gyp,但出现同样的错误。
    猜你喜欢
    • 2021-10-18
    • 2018-01-10
    • 2015-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-27
    相关资源
    最近更新 更多