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.

Can't resolve 'window' in 'project/node_modules/jquery/dist'

See original GitHub issue

Bug report

Can't resolve 'window' in 'project/node_modules/jquery/dist'
Can't resolve 'var define = false' in 'project/node_modules/jquery/dist'

Actual Behavior

In webpack@5.68.0 + imports-loader@3.1.1 can not work.

In webpack.config.js:

{
    test: new RegExp(`(${regExp.join('|')})$`),
    use: [
      {
        loader: 'imports-loader',
        options: {
          additionalCode: 'var define = false; var module = false; var exports = false;',
          wrapper: 'window'
        }
      }
    ]
 }

In webpack@4.41.2 + imports-loader@0.8.0 normal work.

In webpack.config.js:

{
    test: new RegExp(`(${regExp.join('|')})$`),
    loader: 'imports-loader?define=>false&module=>false&exports=>false&this=>window',
}

Please paste the results of npx webpack-cli info here, and mention other relevant information

  System:
    OS: macOS 12.0.1
    CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
    Memory: 595.60 MB / 8.00 GB
  Binaries:
    Node: 12.22.7 - ~/.nvm/versions/node/v12.22.7/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 8.1.3 - ~/.nvm/versions/node/v12.22.7/bin/npm
  Browsers:
    Chrome: 98.0.4758.80
    Firefox: 95.0.2
    Safari: 15.1
  Packages:
    es-webpack-engine: ^4.6.0 => 5.0.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Hongbusicommented, Mar 24, 2022

Solved this problem in other ways. Also thank you very much for the help you provided me. @alexander-akait

0reactions
alexander-akaitcommented, Feb 28, 2022

@Hongbusi Can you reduce complex of the reproducible? I still can’t run your example

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module not found: Error: Can't resolve 'jquery' in webpack #153
Hi, the message recommendation is that run de command npm install --save jquery, i run this command and the error was fixed, hope...
Read more >
Module not found: Error: Can't resolve 'jquery' in - Stack Overflow
try installing jquery on npm, it should solve it. I had that issue on react.js.
Read more >
How to Bundle JavaScript With Rollup — Step-by-Step Tutorial
Author your app or library using ES2015 modules, then efficiently bundle them up into a single file for use in browsers and Node.js....
Read more >
Externals - webpack
The externals configuration option provides a way of excluding dependencies from the output bundles. Instead, the created bundle relies on that dependency ...
Read more >
Documentation - Module Resolution - TypeScript
Module resolution is the process the compiler uses to figure out what an import refers to. Consider an import statement like import {...
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