Webpack构建因Gitlab-CI而失败 [英] Webpack build fails with Gitlab-CI
本文介绍了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']
}
}
},
...
]
https://github.com/babel/babel-loader /issues/370#issuecomment-310378407
这篇关于Webpack构建因Gitlab-CI而失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文