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.

Webpack entry cannot be found after importing filer

See original GitHub issue

Context

I am trying to add FilerWebpackPlugin to an existing Webpack configuration.

Problem

As soon as I require('filer'), Webpack starts failing because it cannot find the entry file anymore.

Analysis

This problem seems to be caused by a side effect in src/path.js:

/**
 * Patch process to add process.cwd(), always giving the root dir.
 * NOTE: this line needs to happen *before* we require in `path`.
 */
process.cwd = () => '/';

Workaround

The only workaround that I found is to save process.cwd before importing filer, and to restore it afterwards.

const cwd = process.cwd;
const filer = require('filer');
process.cwd = cwd;

With this fix, Webpack is able to find the entry file again.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
bcheidemanncommented, Nov 15, 2021

No problem!

@humphd shall we proceed with PR #793 so we can close this issue?

EDIT: I have seen the other issue about the shims not being present in the version distributed through npm - don’t have time to address that until this evening or tomorrow but we should probably ship any fix for that with the fix for this issue imo

0reactions
bcheidemanncommented, Nov 16, 2021

Should be fixed by v1.4.1

Confirmed, the correct files have been pushed to NPM

Read more comments on GitHub >

github_iconTop Results From Across the Web

ERROR in Entry module not found: Error: Cannot resolve 'file ...
Hi everybody. I'm simply trying to use webpack but i can't solve this error. This is my webpack.config.js : module.exports = { entry:...
Read more >
Webpack 5 entry point now failing on imports - Stack Overflow
The project runs with "webpack serve" but I get the error "SyntaxError: Cannot use import statement outside a module" in the entry point...
Read more >
Entry Points - webpack
They must be loaded before this entry point is loaded. filename : Specifies the name of each output file on disk. import :...
Read more >
TypeScript - webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >
Output Management - webpack
Let's fix that with the HtmlWebpackPlugin . Setting up HtmlWebpackPlugin. First install the plugin and adjust the webpack.config.js file: npm ...
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