Hey,
I’m having an issue that I just can’t seem to figure out:
We haver a single runner installed on Linux using docker. We have a staging and master branch from which we do our deployments.
On staging the build works fine with no issue, however on master we are getting the following error
$ npm run build
> ef-storyblok-nextjs@0.0.1 build /builds/education-first/ef-storyblok-nextjs
> next build
NODE_ENV: production
Storyblok API Endpoint: https://app.storyblok.com/v1
phase *** phase-production-build
Warning: No build cache found. Please configure build caching for faster rebuilds. Read more: https://err.sh/next.js/no-cache
Creating an optimized production build...
Attention: Next.js now collects completely anonymous telemetry regarding usage.
This information is used to shape Next.js' roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://nextjs.org/telemetry
Failed to compile.
./node_modules/next/dist/client/next.js
Error: Cannot find module '@babel/core'
babel-loader@8 requires Babel 7.x (the package '@babel/core'). If you'd like to use Babel 6.x ('babel-core'), you should install 'babel-loader@7'.
> Build error occurred
Error: > Build failed because of webpack errors
at build (/builds/education-first/ef-storyblok-nextjs/node_modules/next/dist/build/index.js:10:900)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ef-storyblok-nextjs@0.0.1 build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ef-storyblok-nextjs@0.0.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-01-17T08_18_10_095Z-debug.log
ERROR: Job failed: exit code 1
I’ve tried from the master branch to run this locally and it seems to work fine. Again the build works fine in staging and when we merge to master and our gitlab ci runs the error keeps happening.
This is our Gitlab CI:
image: node:10.5.0
cache:
paths:
- node_modules/
- out/
- .next/cache/
stages:
# - test # this will do unit testing and e2e testing
- publish
- deploy
id_staging_deploy_next_server:
stage: deploy
environment:
name: id_staging
url: https://example.com
before_script:
- export COMMIT_TIME=$(git show -s --format=%ct $CI_COMMIT_SHA)
- export COMMIT_TAG=$(git show -s --format=%H $CI_COMMIT_TAG)
- apt-get update && apt-get install -y zip
- npm config set registry https://npm.ef.com/
- npm config set //npm.ef.com/:_authToken ${EF_NPM_TOKEN}
script:
- npm install
- npm run build
- zip ./builds/server_build_$COMMIT_TAG.zip -rq * .[^.]* .next/\* -x out/\* -x .git/\*
- node -e 'require("./devops/deploy").deployServerBuild()'
only:
refs:
- staging
except:
- triggers
tags:
- e1
- storyblok
id_production_deploy_next_server:
stage: deploy
environment:
name: id_production
url: http://example.com
before_script:
- export COMMIT_TIME=$(git show -s --format=%ct $CI_COMMIT_SHA)
- export COMMIT_TAG=$(git show -s --format=%H $CI_COMMIT_TAG)
- apt-get update && apt-get install -y zip
- npm config set registry https://npm.ef.com/
- npm config set //npm.ef.com/:_authToken ${EF_NPM_TOKEN}
script:
- npm install
- npm run build
- zip ./builds/server_build_$COMMIT_TAG.zip -rq * .[^.]* .next/\* -x out/\* -x .git/\*
- node -e 'require("./devops/deploy").deployServerBuild()'
only:
refs:
- master
except:
- triggers
tags:
- e1
- storyblok
I’m assuming it possibly has something to do with the cache, but I’ve tried to remove the cache we have in the gitlab ci, clear the docker cache and have also upgrade our gitlab-runner from 12.2 to 12.6 and issue still persists. I’ve even registered a new runner and same thing happens on the new one. The code between staging and master is exactly the same.
I’m banging my head on this one as again as the buid works locally, it is not the framework we are using NextJs as it works in the staging gitlab ci build as well. I’m assuming it’s something to do with our runner but can’t figure out what exactly.
Any suggestions would be welcome? Is there a configuration that is causing this? I’m checking on both sides both NextJS community and gitlab CI. Thanks ahead of time for your help and support on this it’s greatly appreciated.