1、错误描述
F:WebstormProjectseuwesa>npm install babel-plugin-component -D
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dnpm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modulesfsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"dar
+ babel-plugin-component@1.1.1
added 4 packages from 3 contributors in 13.118s
F:WebstormProjectseuwesa>npm run dev
> esa@1.0.0 dev F:WebstormProjectseuwesa
> webpack-dev-server --inline --progress --config build/webpack.dev.conf.js
94% asset optimization
ERROR Failed to compile with 2 errors 16:10:44
error in (webpack)-dev-server/client?http://localhost:8081
Module build failed: Error: Couldn't find preset "es2015" relative to directory "F:\WebstormProjects\euw\esa"
at F:WebstormProjectseuwesa
ode_modulesabel-corelib ransformationfileoptionsoption-manager.js:293:19
at Array.map (<anonymous>)
at OptionManager.resolvePresets (F:WebstormProjectseuwesa
ode_modulesabel-corelib ransformationfileoptionsoption-manager.js:275:20)
at OptionManager.mergePresets (F:WebstormProjectseuwesa
ode_modulesabel-corelib ransformationfileoptionsoption-manager.js:264:10)
at OptionManager.mergeOptions (F:WebstormProjectseuwesa
ode_modulesabel-corelib ransformationfileoptionsoption-manager.js:249:14)
at OptionManager.init (F:WebstormProjectseuwesa
ode_modulesabel-corelib ransformationfileoptionsoption-manager.js:368:12)
at File.initOptions (F:WebstormProjectseuwesa
ode_modulesabel-corelib ransformationfileindex.js:212:65)
at new File (F:WebstormProjectseuwesa
ode_modulesabel-corelib ransformationfileindex.js:135:24)
at Pipeline.transform (F:WebstormProjectseuwesa
ode_modulesabel-corelib ransformationpipeline.js:46:16)
at transpile (F:WebstormProjectseuwesa
ode_modulesabel-loaderlibindex.js:50:20)
at Object.module.exports (F:WebstormProjectseuwesa
ode_modulesabel-loaderlibindex.js:173:20)
@ multi (webpack)-dev-server/client?http://localhost:8081 webpack/hot/dev-server ./src/main.js
error in ./src/main.js
Module build failed: Error: Couldn't find preset "es2015" relative to directory "F:\WebstormProjects\euw\esa"
at F:WebstormProjectseuwesa
ode_modulesabel-corelib ransformationfileoptionsoption-manager.js:293:19
at Array.map (<anonymous>)
at OptionManager.resolvePresets (F:WebstormProjectseuwesa
ode_modulesabel-corelib ransformationfileoptionsoption-manager.js:275:20)
at OptionManager.mergePresets (F:WebstormProjectseuwesa
ode_modulesabel-corelib ransformationfileoptionsoption-manager.js:264:10)
at OptionManager.mergeOptions (F:WebstormProjectseuwesa
ode_modulesabel-corelib ransformationfileoptionsoption-manager.js:249:14)
at OptionManager.init (F:WebstormProjectseuwesa
ode_modulesabel-corelib ransformationfileoptionsoption-manager.js:368:12)
at File.initOptions (F:WebstormProjectseuwesa
ode_modulesabel-corelib ransformationfileindex.js:212:65)
at new File (F:WebstormProjectseuwesa
ode_modulesabel-corelib ransformationfileindex.js:135:24)
at Pipeline.transform (F:WebstormProjectseuwesa
ode_modulesabel-corelib ransformationpipeline.js:46:16)
at transpile (F:WebstormProjectseuwesa
ode_modulesabel-loaderlibindex.js:50:20)
at Object.module.exports (F:WebstormProjectseuwesa
ode_modulesabel-loaderlibindex.js:173:20)
@ multi (webpack)-dev-server/client?http://localhost:8081 webpack/hot/dev-server ./src/main.js
2、错误原因
将.babelrc文件中的内容
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-vue-jsx", "transform-runtime"]
}
改为
{
"presets": [["es2015", { "modules": false }]],
"plugins": [
[
"component",
{
"libraryName": "element-ui",
"styleLibraryName": "theme-chalk"
}
]
]
}
3、解决办法
执行一下下面命令:
npm install --save-dev babel-preset-es2015
F:WebstormProjectseuwesa>npm install --save-dev babel-preset-es2015
npm WARN deprecated babel-preset-es2015@6.24.1: ???? Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modulesfsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ babel-preset-es2015@6.24.1
added 1 package from 1 contributor in 9.707s
F:WebstormProjectseuwesa>