Laravel-mix: [Error] Requiring file from vendor directory

Created on 6 Mar 2017  路  4Comments  路  Source: JeffreyWay/laravel-mix

  • Laravel Mix Version: 0.8.1
  • Node Version (node -v): 7.7.1
  • NPM Version (npm -v): 4.1.2
  • OS: MacOS Sierra

Description:

Requiring file from vendor directory gives error:

ERROR Failed to compile with 1 errors 00:54:20

error in /Users/misterio/Dropbox/~Projects/dashkit/resources/assets/js/dashkit.js

Module build failed: Error: Couldn't find preset "es2015" relative to directory "/Users/misterio/Dropbox/~Projects/dashkit/resources/assets/js"
at /Users/misterio/PhpstormProjects/dashkit/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19

app.js:

require('../../../vendor/dashkit/dashkit/resources/assets/js/dashkit');

app.scss:

@import "../../../vendor/dashkit/dashkit/resources/assets/sass/dashkit";

Compiling works if I run yarn or npm install in vendor/dashkit/dashkit directory. Otherwise, it fails.
Also, have to mention that directory vendor/dashkit is symlinked.

Most helpful comment

  • node v 9.11.1
  • npm v5.8.0
  • Laravel Mix v2.1.11

I ran into a similar issue with symlinks using Laravel Mix on an Elixir Phoenix project (I know, not a typical use case). For context, Phoenix framework includes channel support. The recommended package.json dependencies looks like the following for their wheels-included channel support:

{
  "devDependencies": {
    "phoenix": "file:../deps/phoenix",
    "phoenix_html": "file:../deps/phoenix_html",
    "..."
  }
}

Previously, this setup worked fine, but on update to npm version 5.*, npm began symlinking files into node_modules and things began to bomb out when running npm run watch commands. I was able to get back to properly compiling assets by updating the following in webpack.mix.js:

mix.webpackConfig({
  resolve: {
    symlinks: false,
  }
});

All 4 comments

It could be related to the fact that the directory is symlinked. Not sure.

Are you using a custom .babelrc file in your project root?

@JeffreyWay No, I am not using custom .babelrc. Seems that webpack works strange with symlinks.

Yeah, this is a Webpack issue based on how it resolves symlinked paths. It's unrelated to Mix, so we can't do anything about that.

https://github.com/webpack/webpack/issues/1643

  • node v 9.11.1
  • npm v5.8.0
  • Laravel Mix v2.1.11

I ran into a similar issue with symlinks using Laravel Mix on an Elixir Phoenix project (I know, not a typical use case). For context, Phoenix framework includes channel support. The recommended package.json dependencies looks like the following for their wheels-included channel support:

{
  "devDependencies": {
    "phoenix": "file:../deps/phoenix",
    "phoenix_html": "file:../deps/phoenix_html",
    "..."
  }
}

Previously, this setup worked fine, but on update to npm version 5.*, npm began symlinking files into node_modules and things began to bomb out when running npm run watch commands. I was able to get back to properly compiling assets by updating the following in webpack.mix.js:

mix.webpackConfig({
  resolve: {
    symlinks: false,
  }
});
Was this page helpful?
0 / 5 - 0 ratings

Related issues

terion-name picture terion-name  路  3Comments

jpmurray picture jpmurray  路  3Comments

RomainGoncalves picture RomainGoncalves  路  3Comments

Bomavi picture Bomavi  路  3Comments

rlewkowicz picture rlewkowicz  路  3Comments