question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not able to include less file from node_modules

See original GitHub issue

Maybe I’m doing something wrong, but I can’t include a less file from my node_modules folder.

I took a clean install of Laravel 5.4. Next I did:

  • npm install
  • npm install bootstrap
  • Create file resources/assets/less/app.less
  • Added content: @import "node_modules/bootstrap/less/bootstrap";
  • Changed webpack.mix.js file to:
mix.js('resources/assets/js/app.js', 'public/js')
   .less('resources/assets/less/app.less', 'public/css');
  • Run npm run dev

This gives me this error: Module build failed: Can't resolve './node_modules/bootstrap/less/bootstrap.less'

When I install Laravel Elixir and try the same less file, it works perfectly… Hope someone can help. Thanks a lot!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

25reactions
JeffreyWaycommented, Jan 30, 2017

Yeah it’s a less-loader thing. They’ve had an issue up for a year now about this.

The workaround is to use a tilda, like this:

@import "~bootstrap/less/bootstrap";
5reactions
SebastianS90commented, Jan 25, 2017

Try @import "../../../node_modules/bootstrap/less/bootstrap";

Read more comments on GitHub >

github_iconTop Results From Across the Web

Relative path of node_modules for LESS @import
Is there no short hand notation so that the path is relative to project folder? Something like @import ~/node_modules/some-module/style.less ?
Read more >
[Bug] Unable to import LESS files from node_modules via '~'
I am not following what the problem is here, the output of ng-packagr can be used in an Angular CLI project irrespective of...
Read more >
global css cannot be imported from within node_modules.
Global CSS cannot be imported from within node_modules. #6 - GitHub ; import the .less files in your pages/_app instead of importing a...
Read more >
node_modules/less-loader · master - GitLab an der TU Chemnitz
less -loader applies a Less plugin that passes all queries to the webpack resolver if less could not resolve @import . Thus you...
Read more >
Dependency resolution - Parcel
npm : – a way for URL dependencies (e.g. in HTML, CSS, or web workers) to import files from a node_modules package. http:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found