Christos Lytras
Christos Lytras

Reputation: 37327

Laravel 5.5 Webpack dependency was not found

Related SO question: npm - package.json override main field (I tried to do something like this using the webpack.mix.js but it didn't work).

I have a Laravel 5.5 application with npm v5.6.0 and node v9.4.0 (I'm thinking that this maybe is an npm/node version issue, but I don't have an environment to test with older versions ATM). Everything is working fine and I'm working this app for a while now and I've installed some node modules and used bootstrap.js and app.js to require/import npm modules, but it seems there is a problem with the bootstrap-treeview; I've spent more than 2 hours to try and make webpack compile with this module with no luck; I always get that error after npm run dev:

ERROR Failed to compile with 1 errors

This dependency was not found:

  • bootstrap-treeview in ./resources/assets/js/bootstrap.js

I tried to use both require and import inside bootstrap.js and I have even tried an other available module webpack-bootstrap-treeview which it seems that it doesn't have bower dependency:

//import "~/node_modules/bootstrap-treeview";
//require("bootstrap-treeview");
//import "bootstrap-treeview";
//import "~/node_modules/webpack-bootstrap-treeview";
//require("webpack-bootstrap-treeview");
import "webpack-bootstrap-treeview";

bootstrap-treeview: https://www.npmjs.com/package/bootstrap-treeview

webpack-bootstrap-treeview: https://www.npmjs.com/package/webpack-bootstrap-treeview

Laravel Webpack Run Dev Error

I know I can just use laravel-mix to compile the js files directly to the app.js and I will probably do, but I want to have my modules organized and I'd like to find the culprit on this issue.

EDIT

I've also tried to delete the node_modules directory then npm install and even npm cache clear, nothing worked for the webpack to compile without that error.

Upvotes: 0

Views: 589

Answers (1)

ArtS
ArtS

Reputation: 26

Looks like there are some misnamed files. Renaming the bootstrap-treeview files in node_modules\bootstrap-treeview-2\dist to bootstrap-treeview-2 allows webpack to successfully complete. Oh, and I installed the bootstrap-treeview-2 package because bootstrap-treeview has been archived.

Upvotes: 1

Related Questions