Webpack build fails with Gitlab-CI

Asked
Active3 hr before
Viewed126 times

7 Answers

webpackbuild
90%

cloning a fresh copy somewhere else on the server and running webpack works too, Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers ,SSH into the server and run webpack gives the same error,When Gitlab-CI is running my pipeline I get an error in the console:

I solved this issue by changing the babel-loader configuration from

rules: [{
      test: /\.js$/,
      include: path.resolve(__dirname, 'src'),
      exclude: /(node_modules|bower_components|build)/,
      use: {
         loader: 'babel-loader',
         options: {
            presets: ['env']
         }
      }
   },
   ...
]
load more v
88%

Further reading: Using Git submodules with GitLab CI | GitLab Docs,cloning a fresh copy somewhere else on the server and running webpack works too,.gitlab-ci.yml (excerpt):,When Gitlab-CI is running my pipeline I get an error in the console:

When Gitlab-CI is running my pipeline I get an error in the console:

$ npm run build

> project-name@1.0.0 build /home/gitlab-runner/builds/1e932413/0/namespace/project-name
> webpack

using environment 'development'
Hash: 4eb3a28e1a75bb9f8fb5
Version: webpack 3.11.0
Time: 70ms
   Asset     Size  Chunks             Chunk Names
index.js  2.75 kB       0  [emitted]  main
   [0] ./index.js 261 bytes {0} [built] [failed] [1 error]

ERROR in ./index.js
Module parse failed: Unexpected token (10:2)
You may need an appropriate loader to handle this file type.
| const root = props => {
|   return(
|       <Provider store={store}>
|           <MyComponent {...props}/>
|       </Provider>
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! project-name@1.0.0 build: `webpack`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the project-name@1.0.0 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!     /home/gitlab-runner/.npm/_logs/2018-02-14T11_07_48_546Z-debug.log
ERROR: Job failed: exit status 1
load more v
72%

I have a build that works in circle ci on docker image circleci/node:7.10 and custom docker image with node:8.1.2 but fails on gitlab ci on the same images. This is the error,I don't see why it should not work on gitlab ci because the docker images are the same. Maybe some enviorment variables make a problem?, Customer stories →

0
65%

On staging the build works fine with no issue, however on master we are getting the following error,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.,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.,But now I’ve gotten a similar issue for another pipeline and artifacts is not working which is making me realize that I’m still not sure of the exact problem.

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 - 17 T08_18_10_095Z - debug.log
 ERROR: Job failed: exit code 1
load more v
75%

Other issue : gitlab-org/gitlab-ce#29254 ,A error appear on compile.,Build : https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/update/8.16-to-8.17.md#6-install-libs-migrations-etc, Repository Repository Files Commits Branches Tags Contributors Graph Compare Locked Files

# Install / update frontend asset dependencies
sudo - u git - H npm install--production

# Clean up assets and cache
sudo - u git - H bundle exec rake gitlab: assets: clean gitlab: assets: compile cache: clear RAILS_ENV = production
load more v
40%

GitLab provides several tools to help make troubleshooting your pipelines easier. ,If a pipeline does not seem to run at all, with no error message, it may also be due to rules or only/except configuration, or the workflow: rules keyword. , GitLab CI/CD documentation Documentation for pipeline types Troubleshooting Guides for CI/CD features ,Two pipelines run at the same time

# find resource group by name
resource_group = Project.find_by_full_path('...').resource_groups.find_by(key: 'the-group-name')
busy_resources = resource_group.resources.where('build_id IS NOT NULL')

# identify which builds are occupying the resource
#(I think it should be 1 as of today)
busy_resources.pluck(: build_id)

# it 's good to check why this build is holding the resource.
# Is it stuck ? Has it been forcefully dropped by the system ?
   # free up busy resources
busy_resources.update_all(build_id: nil)
22%

If your project requires specific options for your Git submodules, which Travis CI does not support out of the box, turn off the automatic integration and use the before_install hook to initializes and update them.,If your project uses Git submodules, make sure you use public Git URLs. For example, on GitHub, instead of,Restart a build that used to be green, the last known working one, for instance. If that build suddenly fails too, there’s a good chance, that a dependency was updated and is causing the breakage., Restart a build that used to be green, the last known working one, for instance. If that build suddenly fails too, there’s a good chance, that a dependency was updated and is causing the breakage.

if defined ? (RUBY_ENGINE) && RUBY_ENGINE == "ruby" && RUBY_VERSION >= "1.9"
module Kernel
alias: __at_exit: at_exit
def at_exit( & block)
__at_exit do
   exit_status = $!.status
if
$!.is_a ? (SystemExit)
block.call
exit exit_status
if exit_status
end
end
end
end
load more v

Other "webpack-build" queries related to "Webpack build fails with Gitlab-CI"