Home > Blockchain >  NodeJS - no such file or directory, scandir '/static/reports/'
NodeJS - no such file or directory, scandir '/static/reports/'

Time:10-24

I tried following this stackoverflow post to try and see my folder on my static webpage but no luck:enter image description here

Here is a picture of the error from docker: enter image description here

Here is the error from text:

internal/fs/utils.js:269

    throw err;

    ^


Error: ENOENT: no such file or directory, scandir './static/reports'

    at Object.readdirSync (fs.js:955:3)

    at Object.<anonymous> (/app/src/index.js:5:16)

    at Module._compile (internal/modules/cjs/loader.js:999:30)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

    at Module.load (internal/modules/cjs/loader.js:863:32)

    at Function.Module._load (internal/modules/cjs/loader.js:708:14)

    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)

    at internal/main/run_main_module.js:17:47 {

  errno: -2,

  syscall: 'scandir',

  code: 'ENOENT',

  path: './static/reports'

}

CodePudding user response:

Starting a file path with a / denotes that it's at the root of the filesystem. Don't use a /; instead, just use static/reports. You can also use ./static/reports if the code will be run from the src/ directory every time.

var fs = require('fs');
var files = fs.readdirSync('static/reports/');
  • Related