Webpack构建因Gitlab

编程入门 行业动态 更新时间:2024-10-11 17:20:36
本文介绍了Webpack构建因Gitlab-CI而失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当Gitlab-CI运行我的管道时,我在控制台中收到一个错误:

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

我真的不知道是什么原因导致此错误.到目前为止,这是我尝试过的:

I really don't know what causes this error. This is what I have tried so far:

  • SSH进入服务器并运行webpack会给出相同的错误
  • 工作区中的
  • git status报告没有更改
  • 将工作空间复制到其他位置,并且正在运行webpack
  • 在服务器上的其他位置克隆新副本并运行webpack也是可行的
  • SSH into the server and run webpack gives the same error
  • git status in the workspace reports no changes
  • copy the workspace somewhere else and running webpack is working
  • cloning a fresh copy somewhere else on the server and running webpack works too
推荐答案

我通过更改babel-loader配置,解决了此问题

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'] } } }, ... ]

rules: [ { test: /\.js$/, include: path.resolve(__dirname, 'src'), exclude: '/node_modules/', use: { loader: 'babel-loader', options: { presets: ['env'] } } }, ... ]

github/babel/babel-loader /issues/370#issuecomment-310378407

更多推荐

Webpack构建因Gitlab

本文发布于:2023-11-15 22:23:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1598485.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Webpack   Gitlab

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!