请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

Unknown option: .targets.

module.exports={

entry:{

app:'./app.js'

},

output:{

filename:'[name].[hash:8].js'

},

module:{

rules:[

{

test:/\.js$/,

use:{

loader:'babel-loader',

options:{

presets:['@babel/preset-env',{

targets:{

browsers:['>1%','last 2 versions']

}

}]

}

},

exclude:'/node_modules/'

}

]

}

}

错误提示:

ERROR in ./app.js

Module build failed: ReferenceError: [BABEL] G:\2018\webpack3test\day3\app.js: Unknown option: .targets. Check out http://babeljs.io/docs/usage/options/ for more information about options.

    at buildUnknownError (G:\2018\webpack3test\day3\node_modules\@babel\core\lib\config\validation\options.js:97:11)

    at G:\2018\webpack3test\day3\node_modules\@babel\core\lib\config\validation\options.js:83:57

    at Array.forEach (native)

    at validate (G:\2018\webpack3test\day3\node_modules\@babel\core\lib\config\validation\options.js:61:21)

    at G:\2018\webpack3test\day3\node_modules\@babel\core\lib\config\index.js:246:36

    at cachedFunction (G:\2018\webpack3test\day3\node_modules\@babel\core\lib\config\caching.js:40:17)

    at loadPresetDescriptor (G:\2018\webpack3test\day3\node_modules\@babel\core\lib\config\index.js:238:45)

    at G:\2018\webpack3test\day3\node_modules\@babel\core\lib\config\index.js:63:19

    at Array.map (native)

    at recurseDescriptors (G:\2018\webpack3test\day3\node_modules\@babel\core\lib\config\index.js:61:36)

    at loadConfig (G:\2018\webpack3test\day3\node_modules\@babel\core\lib\config\index.js:108:6)

    at G:\2018\webpack3test\day3\node_modules\@babel\core\lib\transform.js:26:33

    at _combinedTickCallback (internal/process/next_tick.js:73:7)

    at process._tickCallback (internal/process/next_tick.js:104:9)


正在回答 回答被采纳积分+3

1回答

qbaty 2018-03-14 12:00:19

你搞错了格式.....

"presets": [
    ["env", {
      "targets": {
        "browsers": ["last 2 versions", "safari >= 7"]
      }
    }]
  ]


1 回复 有任何疑惑可以回复我~
  • 正解,确实少了个中括号  我也遇到了
    回复 有任何疑惑可以回复我~ 2019-05-31 11:55:05
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信