question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Couldn't find preset "es2015" relative to directory

See original GitHub issue

Sorry to add to the flood of extra work, but having a weird issue adding Mix to a project

Just for clarity, this is the migration process that I followed

Updated package.json to contain


  "scripts": {
    "dev": "node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "hot": "node_modules/cross-env/bin/cross-env.js NODE_ENV=development webpack-dev-server --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "production": "node_modules/cross-env/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "devDependencies": {
    "laravel-mix": "^0.5.3"
  }

deleted the old node_modules folder, cleared npm cache, then ran npm install

Started to update the wepack file so far got to

const { mix } = require('laravel-mix');

mix
    .js([
            // Core dependencies
            'theme-assets/frontend-core/vendor/jquery/2.1.4/jquery-2.1.4.min.js',
            'theme-assets/frontend-core/vendor/modernizr/2.8.3/modernizr.min.js',
            'theme-assets/frontend-core/vendor/underscorejs/1.8.3/underscore.min.js',
            'theme-assets/frontend-core/vendor/owlcarousel/2.0.0.2.4/owl.carousel.min.js',
            'theme-assets/frontend-core/vendor/selesti/cookielaw.js',

            // UIKit
            'theme-assets/frontend-core/vendor/uikit/2.23.0/js/uikit.js',
            'theme-assets/frontend-core/vendor/uikit/2.23.0/js/components/sticky.js',
            'theme-assets/frontend-core/vendor/uikit/2.23.0/js/components/slideshow.js',

            // AngularJS
            'theme-assets/frontend-core/vendor/angularjs/1.3.16/angular.min.js',
            'theme-assets/frontend-core/vendor/selesti/selesti-app.js'
        ]), 'public/assets/js/vendor.js');

However when I run npm run dev and webpack kicks in it comes up with

 ERROR  Failed to compile with 10 errors

 error  in ./theme-assets/frontend-core/vendor/selesti/selesti-app.js

Module build failed: Error: Couldn't find preset "es2015" relative to directory "/Users/owen"
    at /Users/owen/Sites/selesti/node_modules/babel-core/lib/transformation/file/options/option-manager.js:292:19
    at Array.map (native)
    at OptionManager.resolvePresets (/Users/owen/Sites/selesti/node_modules/babel-core/lib/transformation/file/options/option-manager.js:274:20)
    at OptionManager.mergePresets (/Users/owen/Sites/selesti/node_modules/babel-core/lib/transformation/file/options/option-manager.js:263:10)
    at OptionManager.mergeOptions (/Users/owen/Sites/selesti/node_modules/babel-core/lib/transformation/file/options/option-manager.js:248:14)
    at OptionManager.init (/Users/owen/Sites/selesti/node_modules/babel-core/lib/transformation/file/options/option-manager.js:367:12)
    at File.initOptions (/Users/owen/Sites/selesti/node_modules/babel-core/lib/transformation/file/index.js:216:65)
    at new File (/Users/owen/Sites/selesti/node_modules/babel-core/lib/transformation/file/index.js:139:24)
    at Pipeline.transform (/Users/owen/Sites/selesti/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
    at transpile (/Users/owen/Sites/selesti/node_modules/babel-loader/lib/index.js:38:20)
    at /Users/owen/Sites/selesti/node_modules/babel-loader/lib/fs-cache.js:78:18
    at ReadFileContext.callback (/Users/owen/Sites/selesti/node_modules/babel-loader/lib/fs-cache.js:14:14)
    at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:365:13)

I’ve checked my node_modules folder and can see that the preset is included.

However for some odd reasons these are not playing ball.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:25 (3 by maintainers)

github_iconTop GitHub Comments

50reactions
gerardojbaezcommented, Apr 23, 2017

I was having the same problem.

  • Node version: v7.8.0 (based on node -v)
  • NPM version: 4.5.0 (based on npm -v)
  • Laravel Mix version: 0.11.3 (based on npm ls laravel-mix)
  • Laravel version: v5.4.19 (based on composer show laravel/framework)

.babelrc file were not in the root directory after npm install. I was having problems with async, await, and other stuff. I have created the .babelrc file and started getting “Couldn’t find preset “es2015” relative to directory” during npm run dev.

This StackOverflow answer suggest to check if babel-preset-es2015 is installed. When I have executed npm ls babel-preset-es2015, nothing was returned.

npm install babel-preset-es2015 --save-dev solved my problem.

22reactions
OwenMelbzcommented, Jan 25, 2017

Noticed if you add your own .babelrc file with

{
    "presets": [
        ["es2015", { "modules": false }]
    ]
}

it solves the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Couldn't find preset "es2015" relative to directory "/Users ...
To fix this issue You should remove .babelrc (hidden) file from "/Users/username" directory.
Read more >
Couldn't find preset "es2015" relative to directory #93 - GitHub
I use gulp-babel in electron,I have all the dependencies installed. the code is : function compileJs(cb) { gulp.src(paths.src.js) ...
Read more >
【Bug】Vue解决Couldn't find preset "es2015" relative to ...
Couldn't find preset “es2015” relative to directory原因由于引入的Element-UI 使用了ES标准,所以编译会报错。解决方法安装ES 标准npm install ...
Read more >
Couldn't find preset "es2015" relative to directory-Reactjs
Coding example for the question Webpack + Babel: Couldn't find preset "es2015" relative to directory-Reactjs.
Read more >
Module build failed: Error: Couldn't find preset "es2015" relative to ...
Module build failed: Error: Couldn't find preset "es2015" relative to directory.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found