E
E
ekzotika2020-07-08 21:09:35
Node.js
ekzotika, 2020-07-08 21:09:35

Why am I getting the error Error: ENOENT: no such file or directory, scandir?

I'm trying to run the command I'm npm run-script watch

getting the following error:
Error: ENOENT: no such file or directory, scandir

Log:

> [email protected] watch C:\JOB\promocatalog\front
> webpack --mode development --progress --watch

C:\JOB\promocatalog\front\node_modules\webpack-cli\bin\cli.js:93
                                throw err;
                                ^

Error: ENOENT: no such file or directory, scandir
    at Object.readdirSync (fs.js:974:3)
    at Object.<anonymous> (C:\JOB\promocatalog\front\webpack.config.js:26:26)
    at Module._compile (C:\JOB\promocatalog\front\node_modules\v8-compile-cache\v8-compile-cache.js:194:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32)
    at Function.Module._load (internal/modules/cjs/loader.js:937:14)
    at Module.require (internal/modules/cjs/loader.js:1089:19)
    at require (C:\JOB\promocatalog\front\node_modules\v8-compile-cache\v8-compile-cache.js:161:20)
    at WEBPACK_OPTIONS (C:\JOB\promocatalog\front\node_modules\webpack-cli\bin\utils\convert-argv.js:114:13)
    at requireConfig (C:\JOB\promocatalog\front\node_modules\webpack-cli\bin\utils\convert-argv.js:116:6)
    at C:\JOB\promocatalog\front\node_modules\webpack-cli\bin\utils\convert-argv.js:123:17
    at Array.forEach (<anonymous>)
    at module.exports (C:\JOB\promocatalog\front\node_modules\webpack-cli\bin\utils\convert-argv.js:121:15)
    at C:\JOB\promocatalog\front\node_modules\webpack-cli\bin\cli.js:71:45
    at Object.parse (C:\JOB\promocatalog\front\node_modules\yargs\yargs.js:576:18)
    at C:\JOB\promocatalog\front\node_modules\webpack-cli\bin\cli.js:49:8
    at Object.<anonymous> (C:\JOB\promocatalog\front\node_modules\webpack-cli\bin\cli.js:366:3)
    at Module._compile (internal/modules/cjs/loader.js:1200:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32)
    at Function.Module._load (internal/modules/cjs/loader.js:937:14)
    at Module.require (internal/modules/cjs/loader.js:1089:19)
    at require (internal/modules/cjs/helpers.js:73:18)
    at Object.<anonymous> (C:\JOB\promocatalog\front\node_modules\webpack\bin\webpack.js:156:2)
    at Module._compile (internal/modules/cjs/loader.js:1200:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32)
    at Function.Module._load (internal/modules/cjs/loader.js:937:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  errno: -4058,
  syscall: 'scandir',
  code: 'ENOENT'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] watch: `webpack --mode development --progress --watch`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] watch script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Stepa\AppData\Roaming\npm-cache\_logs\2020-07-08T14_34_22_349Z-debug.log


Tell me, please, what could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Vasiliev, 2022-04-12
@Isolution666

It can't find the directory and webpack can't build it.
You must have an absolute path in the path to read files. __dirname
Example:

path: path.join(__dirname, `../static/images/${id}.png`)

Specify the correct directory before the file, then the file will be found and there will be no "directory error", perhaps there is no file itself, then you need to put it there. It is better, of course, to check that if the file does not exist, then show something else, some kind of message, if everything is ok, show the file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question