当Gitlab-CI运行我的管道时,我在控制台中收到错误:
$ 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
我真的不知道导致此错误的原因。这是我到目前为止所尝试的:
webpack
会出现同样的错误git status
报告无更改webpack
正在运行 webpack
也可以答案 0 :(得分:2)
我通过改变
中的babel-loader配置解决了这个问题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