折腾:
期间,代码配置:
.babelrc
{ “presets”: [ “env”, “stage-0”, “react”, “es2015”, “stage-1” ], “plugins”: [ “transform-decorators-legacy”, “transform-runtime”, “react-hot-loader/babel” ] } |
npm run dev出错:
ERROR in ./src/app.entry.js Module build failed: Error: Couldn’t find preset “es2015” relative to directory “/Users/crifan/dev/dev_root/xxx” at /Users/crifan/dev/dev_root/xxx/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19 at Array.map (native) at OptionManager.resolvePresets (/Users/crifan/dev/dev_root/xxx/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20) at OptionManager.mergePresets (/Users/crifan/dev/dev_root/xxx/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10) at OptionManager.mergeOptions (/Users/crifan/dev/dev_root/xxx/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14) at OptionManager.init (/Users/crifan/dev/dev_root/xxx/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12) at File.initOptions (/Users/crifan/dev/dev_root/xxx/node_modules/babel-core/lib/transformation/file/index.js:212:65) at new File (/Users/crifan/dev/dev_root/xxx/node_modules/babel-core/lib/transformation/file/index.js:135:24) at Pipeline.transform (/Users/crifan/dev/dev_root/xxx/node_modules/babel-core/lib/transformation/pipeline.js:46:16) at transpile (/Users/crifan/dev/dev_root/xxx/node_modules/babel-loader/lib/index.js:49:20) at Object.module.exports (/Users/crifan/dev/dev_root/xxx/node_modules/babel-loader/lib/index.js:174:20) @ multi (webpack)-dev-server/client?http://localhost:4000 webpack/hot/dev-server ./src/app.entry.js |
Error: Couldn’t find preset “es2015” relative to directory
新手遇到问题 Couldn’t find preset “es2015” relative to directory · Issue #3 · 94dreamer/webpack
Couldn’t find preset “es2015” relative to directory · Issue #158 · JeffreyWay/laravel-mix
Couldn’t find preset “es2015” relative to directory · Issue #93 · babel/gulp-babel
去安装:
babel-preset-es2015
babel-preset-stage-2
npm install babel-preset-es2015 babel-preset-stage-2
➜ rse_web git:(master) ✗ npm install babel-preset-es2015 babel-preset-stage-2 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! rse-web@1.0.0 /Users/crifan/dev/dev_root/xxx ├── babel-preset-es2015@6.24.1 └─┬ babel-preset-stage-0@6.24.1 └─┬ babel-preset-stage-1@6.24.1 └─┬ babel-preset-stage-2@6.24.1 ├── babel-plugin-syntax-dynamic-import@6.18.0 ├─┬ babel-plugin-transform-class-properties@6.24.1 │ └── babel-plugin-syntax-class-properties@6.13.0 ├─┬ babel-plugin-transform-decorators@6.24.1 │ └─┬ babel-helper-explode-class@6.24.1 │ └── babel-helper-bindify-decorators@6.24.1 └─┬ babel-preset-stage-3@6.24.1 ├─┬ babel-plugin-transform-async-generator-functions@6.24.1 │ └── babel-plugin-syntax-async-generators@6.13.0 └─┬ babel-plugin-transform-object-rest-spread@6.26.0 ├── babel-plugin-syntax-object-rest-spread@6.13.0 └─┬ babel-runtime@6.26.0 ├── core-js@2.5.1 └── regenerator-runtime@0.11.0 npm WARN react-dom@15.6.1 requires a peer of react@^15.6.1 but none was installed. npm WARN react-month-picker@1.3.0 requires a peer of react@^15.5.4 but none was installed. npm WARN react-month-picker@1.3.0 requires a peer of react-dom@^15.5.4 but none was installed. npm WARN react-tapper@0.1.14 requires a peer of react@^15.5.4 but none was installed. npm WARN react-tapper@0.1.14 requires a peer of react-dom@^15.5.4 but none was installed. |
【总结】
此处去安装:
npm install babel-preset-es2015 babel-preset-stage-2
即可消除警告:
Module build failed Error Couldn’t find preset es2015 relative to directory
转载请注明:在路上 » 【已解决】ReactJS中使用Mobx出错:Module build failed Error Couldn’t find preset es2015 relative to directory