laravel-mix: Couldn't find preset "es2015" relative to directory
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.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 25 (3 by maintainers)
I was having the same problem.
node -v)npm -v)npm ls laravel-mix)composer show laravel/framework).babelrcfile were not in the root directory afternpm install. I was having problems withasync,await, and other stuff. I have created the.babelrcfile and started getting “Couldn’t find preset “es2015” relative to directory” duringnpm run dev.This StackOverflow answer suggest to check if
babel-preset-es2015is installed. When I have executednpm ls babel-preset-es2015, nothing was returned.npm install babel-preset-es2015 --save-devsolved my problem.Noticed if you add your own
.babelrcfile withit solves the issue.
in .babelrc add:
{ "presets": [["env", {"modules": false}]] }I have added comment because I had this problem last one hour and found that using ‘es2015’ deprecated and should use ‘env’
@JeffreyWay I can confirm the issue that I had to add a .babelrc to my project root on a brand spanking new install of Laravel 5.4.6. I added this to .babelrc:
Everything worked fine after that.
@JeffreyWay The only thing I could figure out is that for some reason the path is not being appended properly when no .babelrc is present. Even directly injecting the string did not produce any detectable result. However, I did come up with a work around until I have more time to investigate. All I did was change the
babelConfig()slightly to produce a .babelrc file if none is present.Or, you can add this to package.json and forget creating a new .babelrc:
On Fri, Feb 3, 2017 at 11:46 AM, Jeffrey Way notifications@github.com wrote:
–
Ed ejdelmonico@gmail.com (702) 510-8380
It should automatically apply that
.babelrcconfig if you don’t have one in your project root.