Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watchpack Error (watcher): Error: EACCES #15297

Closed
melsiir opened this issue Feb 1, 2022 · 2 comments
Closed

Watchpack Error (watcher): Error: EACCES #15297

melsiir opened this issue Feb 1, 2022 · 2 comments

Comments

@melsiir
Copy link

melsiir commented Feb 1, 2022

Bug report

What is the current behavior?

I am trying to use my react webpack setup on my Android system but this watcher warning annoying I don't know why it trying to watch system root directory which should not be accessible to users unless they have root access : Watchpack Error (watcher): Error: EACCES: permission denied, watch '/data/data' Watchpack Error (watcher): Error: EACCES: permission denied, watch '/data' Watchpack Error (initial scan): Error: EACCES: permission denied, scandir '/data/data' Watchpack Error (initial scan): Error: EACCES: permission denied, scandir '/data'

This my project cwd where home directory is my $HOME I don't know why webpack trying to go beyond that :

/data/data/com.termux/files/home/react

I tried to ignore the data/ directory by adding this option in webpack config :

watchOptions: { ignored: [”../../../../../../"] } But this make hot reloading stop working anyone had experienced this before I will appreciate help

If the current behavior is a bug, please provide the steps to reproduce.

Just launch devServer it happened also with npx create-next-app
What is the expected behavior?

No warrnigs

Other relevant information:
webpack version: 5.57.0
Node.js version: v17.4.0
Operating System: Android 10
Additional tools: termux terminal

@alexander-akait
Copy link
Member

Duplicate webpack/watchpack#187

@liujingbreak
Copy link

liujingbreak commented Apr 21, 2023

I fixed (hacked) this error for Termux with a customized Webpack plugin to
remove those EACCES directories from compilation.fileDependencies

import {Compiler} from 'webpack';

const TERMUX_DIR = '/data/data/com.termux';

export function isTermux() {
  return process.cwd().startsWith(TERMUX_DIR);
}

export class TermuxWebpackPlugin {
  apply(compiler: Compiler) {
    if (!isTermux())
      return;
    const lookupDirs = [] as string[];
    for (const item of TERMUX_DIR.split('/')) {
      const dir = ((lookupDirs.length > 0 ? lookupDirs[lookupDirs.length - 1] : '') +
                 '/' + item).replace(/^\/\//, '/');

      // eslint-disable-next-line no-console
      console.log('[TermuxIssueWebpackPlugin] Termux directory', dir);
      lookupDirs.push(dir);
    }
    const lookupSet = new Set<string>(lookupDirs);

    compiler.hooks.done.tap('TermuxIssueResolve', stats => {
      for (const item of stats.compilation.fileDependencies) {
        if (lookupSet.has(item)) {
          // eslint-disable-next-line no-console
          console.log('[TermuxIssueWebpackPlugin] remove unaccessible fileDependency', item);
          stats.compilation.fileDependencies.delete(item);
        }
      }
    });
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants