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.

Hi @sumneuron

Are you able to post the full .gitlab-ci.yml file? My guess is that the two environments are using different Docker images, with different versions of Node / npm / …

image: node

before_script:
  - npm install

cache:
  paths:
    - node_modules/

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

OK, so where you have image: node that’s defining a Docker image, and each pipeline job runs inside a container created from that image.

If I were you, I’d look through the netlify logs and try to find out exactly which version of the Node Docker image is being used there, then pin the GitLab pipeline to that image version, for example image: node:16.

@snim2

Running with gitlab-runner 13.11.0-rc1 (286f7013)
2  on docker-auto-scale z3WU8uu-
3  feature flags: FF_GITLAB_REGISTRY_HELPER_IMAGE:true

4
Preparing the "docker+machine" executor
00:37
5Using Docker executor with image node ...
6Pulling docker image node ...
7Using docker image sha256:d2850632b60222a2c2a4848d6482d69e26435be1718c8de1f946d1f597117133 for node with digest node@sha256:6cbc150709d59d2667f5d34cbf03fb4594dc8b34acb8872f9ab27ba915b28b56 ...

9
Preparing environment

what node version is this?
Also, why doesn’t it include python in the latest version?

Which node version is this? This line in your log gives you a clue:

7Using docker image sha256:d2850632b60222a2c2a4848d6482d69e26435be1718c8de1f946d1f597117133 for node with digest node@sha256:6cbc150709d59d2667f5d34cbf03fb4594dc8b34acb8872f9ab27ba915b28b56 ...

So, you might be able to search for that SHA. However, you could equally just write a little .gitlab-ci.yml file in a test repo like this:

image: node

stages:
  - stage1

workflow:
  rules:
    - if: $CI_MERGE_REQUEST_ID
      when: never
    - when: always

job1:
  stage: stage1
  script:
    - node --version
    - npm --version
    - which python3
    - which python

And that gives you:

Running with gitlab-runner 14.6.0~beta.32.g32ec9f58 (32ec9f58)
  on green-5.shared.runners-manager.gitlab.com/default xS6Vzpvo
Preparing the "docker+machine" executor
Using Docker executor with image node ...
Pulling docker image node ...
Using docker image sha256:058747996654fd76a7dee9c78a51855574443bcdfb25dd1c2766f17105fb28e1 for node with digest node@sha256:13621aa823b6b92572d19c08a75f7b1a061633089f37873f8b5bedb5e900e657 ...
Preparing environment
00:02
Running on runner-xs6vzpvo-project-13243019-concurrent-0 via runner-xs6vzpvo-shared-1639080761-685fa470...
Getting source from Git repository
00:02
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/snim2/scratch-space/.git/
Created fresh repository.
Checking out ecae0315 as test/branch...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:01
Using docker image sha256:058747996654fd76a7dee9c78a51855574443bcdfb25dd1c2766f17105fb28e1 for node with digest node@sha256:13621aa823b6b92572d19c08a75f7b1a061633089f37873f8b5bedb5e900e657 ...
$ node --version
v17.2.0
$ npm --version
8.1.4
$ which python3
/usr/bin/python3
$ which python
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1

So, you have Python there, but it’s Python 3.

You might want to look through the available images on Docker Hub to see which would suite you best, and then pin that in your .gitlab-ci.yml file.

I tried this and I don’t understand what it is and why it just totally fails.

It’s not really clear to me exactly what you tried and what results you got…