Laravel-mix: Babel fails if the js file destination is not on a child directory

Created on 1 Jun 2017  路  6Comments  路  Source: JeffreyWay/laravel-mix

  • Laravel Mix Version: 0.12.1 (npm list --depth=0)
  • Node Version (node -v): 6.10.3
  • NPM Version (npm -v): 5.0.1
  • OS: OS X El Capitan 10.11.6

Description:

I have a project where the asset management is handled on a

Babel fails if the js file destination is not on a child directory, and triggers the Module build failed: Error: Couldn't find preset "env" relative to directory ... error.

Steps To Reproduce:

File structure:

/assets
    webpack.mix.js
    webpack.mix.js
    package.json
    js/
        app.js
    sass/
        app.sass
/application
    /frontend
        /js
       /css

Mix code

mix.js('js/app.js', './../application/frontend/js/app.js'); // fails

// If the dest is a child directory, there is no problem
mix.js('js/app.js', 'foo/foo.js');

All 6 comments

I'm having the same error :(

Try replacing mix.js() with mix.scripts() and see if it works.

Fixed in 1.0+.

Still having this issue on version 1.2.2.

I have the following:

mix.js('./js/app.js', './js/app.js');

and inside I do:

import "phoenix_html"

and as a result I get the following error:

Module build failed: Error: Couldn't find preset "env" relative to directory "../deps/phoenix_html/priv/static"

(I have edited the path in the error to be relative instead of static).

EDIT: @ruchern .scripts doesnt work. It removes the error from the terminal and puts it in the web console.

I'm having this issue as well. We have a shared js library outside of our laravel project that doesn't get imported and throws the Couldn't find preset "env" relative to directory error when compiling. This actually works fine in versions before 1.

@JeffreyWay still getting this error here

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wendt88 picture wendt88  路  3Comments

rlewkowicz picture rlewkowicz  路  3Comments

stefensuhat picture stefensuhat  路  3Comments

kpilard picture kpilard  路  3Comments

amin101 picture amin101  路  3Comments