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.

[webpack2] loader modules resolved only from root

See original GitHub issue

If I have config:

module: {
  loaders: [
    {test: /\.css$/, loader: 'style!css'}
  ]
},
resolve: {
  modules: ['node_modules', __dirname + '/client/node_modules'],
  moduleExtensions: ["-loader"],
}

if install style-loader into /client/node_modules It will not find it, and have to install it to /node_modules. Though resolution from /client/node_modules works inside app’s code.

Issue Analytics

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

github_iconTop GitHub Comments

5reactions
guybedfordcommented, Sep 15, 2016

@sokra thanks for copying me in. I’m not completely sure I follow the details, but perhaps you can ensure that the System global is overridden before using the loader-runner? SystemJS originally didn’t override System if it didn’t already exist, but we had to add override behaviour because Traceur was overriding the global System. Unfortunately we’ve passed this virus on 😃

4reactions
sergei-startsevcommented, Jan 21, 2017

@bebraw It’s still relevant, I came across this issue with webpack 2.2.0-rc.7. I use systemjs and systemjs-builder modules together with webpack in scope of one node.exe process. Here’s the output of failed webpack bundles:

Module build failed: (SystemJS) ENOENT: no such file or directory, open 'd:\\<local_path>\\d:\\<local_path>\\node_modules\\babel-loader\\lib\\index.js'
    Error: ENOENT: no such file or directory, open 'd:\\<local_path>\\d:\\<local_path>\\node_modules\\babel-loader\\lib\\index.js'
        at Error (native)
   Error loading d:/<local_path>/d:\\<local_path>\\node_modules\\babel-loader\\lib\\index.js

I’ve tried to get rid of systemjs dependencies and webpack worked properly for me. As a temporary solution I’ve removed global variable System:

delete global.System;

SystemJS Builder doesn’t use that global variable, so it looks like it doesn’t affect it, anyway I’ve not caught any issues.

@whitecolor Does it make sense to reopen it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolve
Resolve. These options change how modules are resolved. Webpack provides reasonable defaults, but it is possible to change the resolving in detail.
Read more >
Having problems with resolve.root - webpack
Webpack says it can't resolve it. Thanks. EDIT: The problem was that I was using 2.0.0-beta. I downgraded to 1.12.12 and it works....
Read more >
sass-loader
The sass-loader uses Sass's custom importer feature to pass all queries to the Webpack resolving engine. Thus you can import your Sass modules...
Read more >
How to transpile ES modules with webpack and Node.js
This means that loaders can also run in the Node.js environment and, therefore, also follow the module resolution standard. Loader naming ...
Read more >
Module not found: Can't resolve 'babel-loader'
To solve the error Module not found: Error: Can't resolve 'babel-loader', ... --save-dev babel-loader @babel/core @babel/preset-env webpack # 👇️ ONLY If ...
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