-
Notifications
You must be signed in to change notification settings - Fork 809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Couldn't find preset "es2015" relative to directory #158
Comments
Make sure you update npm and node to the latest versions. Here are the versions that I use and they work: node@v6.9.4 |
Currently using slightly newer versions. npm - 3.10.8 Its worth noting it works on a clean laravel 5.4 project |
In fact, I've just tried on another project and getting the same issue. ERROR Failed to compile with 2 errors
error in ./resources/assets/js/app.js
Module build failed: Error: Couldn't find preset "es2015" relative to directory "/Users/owen"
at /Users/owen/Sites/footy-finance/node_modules/babel-core/lib/transformation/file/options/option-manager.js:292:19
at Array.map (native)
at OptionManager.resolvePresets (/Users/owen/Sites/footy-finance/node_modules/babel-core/lib/transformation/file/options/option-manager.js:274:20)
at OptionManager.mergePresets (/Users/owen/Sites/footy-finance/node_modules/babel-core/lib/transformation/file/options/option-manager.js:263:10)
at OptionManager.mergeOptions (/Users/owen/Sites/footy-finance/node_modules/babel-core/lib/transformation/file/options/option-manager.js:248:14)
at OptionManager.init (/Users/owen/Sites/footy-finance/node_modules/babel-core/lib/transformation/file/options/option-manager.js:367:12)
at File.initOptions (/Users/owen/Sites/footy-finance/node_modules/babel-core/lib/transformation/file/index.js:216:65)
at new File (/Users/owen/Sites/footy-finance/node_modules/babel-core/lib/transformation/file/index.js:139:24)
at Pipeline.transform (/Users/owen/Sites/footy-finance/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
at transpile (/Users/owen/Sites/footy-finance/node_modules/babel-loader/lib/index.js:38:20)
at /Users/owen/Sites/footy-finance/node_modules/babel-loader/lib/fs-cache.js:78:18
at ReadFileContext.callback (/Users/owen/Sites/footy-finance/node_modules/babel-loader/lib/fs-cache.js:14:14)
at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:365:13)
@ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss ./resources/assets/sass/admin.scss this is the app.js require('./bootstrap');
/**
* Next, you'll be able to start including your application specific functionality
*/
window.App = App = angular.module('App', ['ngAnimate'], ['$interpolateProvider', function($interpolateProvider) {
// Tell angular to use different templating tags
$interpolateProvider.startSymbol('<%');
$interpolateProvider.endSymbol('%>');
}]);
// Filters
// Directives
require('./directives/FancyFormLabel');
require('./directives/DateDropper');
require('./directives/ProgressCircle');
// Services
require('./services/MenuService');
// Controllers
require('./controllers/GlobalController');
require('./controllers/QuestionController'); this is the other package.json {
"private": true,
"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.0"
},
"dependencies": {
"angular": "^1.6.0",
"angular-animate": "^1.6.0",
"animate.css": "^3.5.2",
"datedropper": "^2.0.0",
"hammerjs": "^2.0.8",
"jquery": "^3.1.1",
"progressbar.js": "^1.0.1",
"responsive-iframe": "^0.0.1",
"selesti-blockui": "^1.0.0",
"uikit": "^2.27.2"
},
"sasslintConfig": "./.sass-lint.yml",
"eslintConfig": "./.eslintrc.yml"
} |
Noticed if you add your own {
"presets": [
["es2015", { "modules": false }]
]
} it solves the issue. |
It should automatically apply that |
@JeffreyWay I did not have the Thus it was generating the automated one from within However once I added my own one (I actually just copy/pasted it from the js file) it then started working. Its almost like its not picking up the root correctly when using the automatic generated one. I've tried it using bash, sh, zsh and fsh just incase it was any bash settings cocking up the paths - and they all produce the same result. I'm happy to provide you with an other information that might help resolve the issue which might be affecting other users if you need. |
@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. |
If any of you guys want to do some digging to figure out why it's not referencing our default Babel config, here's the code that performs the check. https://github.com/JeffreyWay/laravel-mix/blob/master/src/Mix.js#L145-L157 I can't reproduce this. I've never had to manually create the file. |
@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.
```
/**
* Fetch the appropriate Babel config for babel-loader.
*/
babelConfig() {
let file = this.Paths.root('.babelrc');
// If the user has defined their own .babelrc file,
// the babel-loader will automatically fetch it.
// Otherwise, we'll use these defaults.
// return this.File.exists(file) ? '?cacheDirectory' : '?' +
JSON.stringify({
// 'cacheDirectory': true,
// 'presets': [
// ['es2015', { 'modules': false }]
// ]
// });
//
let root = path.resolve(this.Paths.rootPath);
let babelConfig = new File(root +
'/.babelrc').write(JSON.stringify({ "presets": [["es2015", { "modules":
false }]] }));
return this.File.exists(file) ? '?cacheDirectory' : babelConfig;
}
```
Or, you can add this to package.json and forget creating a new .babelrc:
```
"babel": {
"presets": [
"es2015"
]
},
```
…On Fri, Feb 3, 2017 at 11:46 AM, Jeffrey Way ***@***.***> wrote:
If any of you guys want to do some digging to figure out why it's not
referencing our default Babel config, here's the code that performs the
check.
https://github.com/JeffreyWay/laravel-mix/blob/master/src/Mix.js#L145-L157
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#158 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABvxshIKiMsEMuJdzTy74PuRB0FWeUiaks5rY4QPgaJpZM4LtUaf>
.
--
*Ed*
ejdelmonico@gmail.com
(702) 510-8380
|
For me it manifested differently: I could actually compile without error, but when I ran the application, it showed that exact error in the browser console. After upgrading to the most recent versions of node & npm (and recompiling) it seems to work now. Weird. npm - 4.1.2 |
I don't think this is relevant anymore, after the latest update. So closing. |
I was having the same problem.
This StackOverflow answer suggest to check if
|
@gerardojbaez Actually you do not have to install any babel packages as it should have been in Laravel-Mix already. I had the same problem as you just 2 days ago, what I did was to delete the whole Since Laravel Framework comes by default without |
The key word being "should" But I can also confirm this has happened several times on different computers. Sometimes it just doesn't. And the only way to start getting it to work is by manually installing the presets then adding a .babelrc We're all aware that you SHOULDNT need to do this. But that's why it's being bought up as a bug - because it's not working as it SHOULD |
@OwenMelbz Okay I understood your point here, but my solution serves an alternative for whoever that has the same problem but does not want to manually create the We'll wait and see what @JeffreyWay says, regarding this. |
@ruchern I have tried that without success. @OwenMelbz You're completely right. |
I am still getting this error in WebStorm. Why does everyone think that a "workaround" is a proper fix for a horrible user experience? |
@megamindbrian I do not at all believe that everyone feels a work around is the answer. It is represented as a quick solution to a nagging issue with npm installs. The problem stems from npm or yarn does not install all packages properly and the most common issue is "Couldn't find preset "es2015" relative to directory". I have had to nuke the node_modules directory several times to get all the packages installed properly so that Mix will work. For this reason, and type of reason, people tend to comment the quick fix because it is the simple way. If you have a solution, please feel free to submit a pull request to Jeffrey. I am sure he will look closely at it. |
@ejdelmonico I remembered Jeffery did ask users to nuke |
May be I can not figure out the process step by step, I am seeking help for couple of weeks. I will be very much grateful to you if you could assist me solving this issue. I am using Shapecss. The error is showing for
.....................................................................................
..................................................................................... Any help can save my life... :) |
Just ran into the same problem. This is what worked for me: https://stackoverflow.com/a/36821986/33203 |
@ashokgelal Was that a response to @MicroDreamIT ? It looks like /assets/js/ is something included after compilation is already finished. Is assets is already packed and ready, it should be excluded from the compile step using webpack's exclude pattern matching. |
@JeffreyWay I was more referring to the fact that the issue was closed without continuation or path to resolve the issue in a new thread. |
@megamindbrian here is ref, MicroDreamIT/shapecss-framework#2 |
in .babelrc add:
I have added comment because I had this problem last one hour and found that using 'es2015' deprecated and should use 'env' |
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
deleted the old node_modules folder, cleared npm cache, then ran
npm install
Started to update the wepack file so far got to
However when I run
npm run dev
and webpack kicks in it comes up withI've checked my
node_modules
folder and can see that the preset is included.However for some odd reasons these are not playing ball.
The text was updated successfully, but these errors were encountered: