Build on Netlify works but fails on GitLab: GitLab Runners Issue? (Nuxtjs)

Hello!
Total noob here.
For a while I had my site hosted both here and on GitLab pages. Using near identical scripts:

// from package.json
// .. inside "scripts"
   "generate:gitlab-pages": "DEPLOY_ENV=GITLAB_PAGES nuxt generate",
    "generate:netlify": "DEPLOY_ENV=NETLIFY nuxt generate",

The difference between the two being the configuration of the baseurl (as GitLab pages is namespaced).

Aside from that they are identical. It works on Netlify. Fails on GitLab. The error on GitLab is:

...
npm ERR! code 1
52npm ERR! path /builds/MyUsername/my-project-name/node_modules/deasync
53npm ERR! command failed
54npm ERR! command sh -c node ./build.js
55npm ERR! gyp info it worked if it ends with ok
56npm ERR! gyp info using node-gyp@3.8.0
57npm ERR! gyp info using node@17.2.0 | linux | x64
58npm ERR! gyp ERR! configure error 
59npm ERR! gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
60npm ERR! gyp ERR! stack     at PythonFinder.failNoPython (/builds/MyUsername/my-project-name/node_modules/node-gyp/lib/configure.js:484:19)
61npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (/builds/MyUsername/my-project-name/node_modules/node-gyp/lib/configure.js:406:16)
62npm ERR! gyp ERR! stack     at F (/builds/MyUsername/my-project-name/node_modules/node-gyp/node_modules/which/which.js:68:16)
63npm ERR! gyp ERR! stack     at E (/builds/MyUsername/my-project-name/node_modules/node-gyp/node_modules/which/which.js:80:29)
64npm ERR! gyp ERR! stack     at /builds/MyUsername/my-project-name/node_modules/node-gyp/node_modules/which/which.js:89:16
65npm ERR! gyp ERR! stack     at /builds/MyUsername/my-project-name/node_modules/isexe/index.js:42:5
66npm ERR! gyp ERR! stack     at /builds/MyUsername/my-project-name/node_modules/isexe/mode.js:8:5
67npm ERR! gyp ERR! stack     at FSReqCallback.oncomplete (node:fs:198:21)
68npm ERR! gyp ERR! System Linux 5.4.109+
69npm ERR! gyp ERR! command "/usr/local/bin/node" "/builds/MyUsername/my-project-name/node_modules/.bin/node-gyp" "rebuild"
70npm ERR! gyp ERR! cwd /builds/MyUsername/my-project-name/node_modules/deasync
71npm ERR! gyp ERR! node -v v17.2.0
72npm ERR! gyp ERR! node-gyp -v v3.8.0
73npm ERR! gyp ERR! not ok 
74npm ERR! Build failed
75npm ERR! A complete log of this run can be found in:
76npm ERR!     /root/.npm/_logs/2021-12-07T00_25_59_323Z-debug.log

78
Cleaning up project directory and file based variables
00:00
80ERROR: Job failed: exit code 1

What do I do?
I don’t know enough to begin even trying to debug. I googled the python thing and StackOverflow says something about maybe NPM v16? Not sure.

One of the node packages in your project has node-gyp as a dependency, which in turn requires Python.

Error: Can't find Python executable "python", you can set the PYTHON env variable.

The build image that Netlify use has a lot of things pre-installed, which is probably why it worked there automatically.

To fix you’ll need to ensure that python is available when running on GitLab.

As you’re not having any problem with Netlify, if you continue to have GitLab specific issues, you may wish to reach out to their support.

2 Likes

Do you know how I do that?

I’d search Google for a solution.

A starting point though would be to check your gitlab-ci.yml and determine what build image you’re currently using.

Regardless of where you’re executing your build (locally, or remotely with any provider), you want to ensure that your build has access to all of the dependencies it requires.

image: node

before_script:
  - npm install

cache:
  paths:
    - node_modules/

pages:
  script:
    - npm run generate:gitlab-pages
  artifacts:
    paths:
      - public
  only:
    - master

no idea what version I am using

The build image is specified as that first line:

The GitLab docs provide more detail:

I believe the image is:
https://hub.docker.com/_/node

As none of this concerns Netlify and only your project and GitLab, this isn’t the right place to request assistance. You should familiarise yourself with the relevant GitLab documentation and if you’re unable to self-solve request assistance in a more GitLab centric support environment, or somewhere generic like Stack Overflow.

Thank you for all the help so far. I posted here because it was suggested that since it worked on Netlify and not GitLab that maybe someone smart would know