mamamia5x / markdownpedia

A site similar to Wikipedia written in Markdown.
https://markdownpedia.tk/
Other
16 stars 33 forks source link

Error: ENOTDIR on macOS Big Sur (11.2) #33

Closed Marie-P closed 3 years ago

Marie-P commented 3 years ago

Hello,

I got an error on macOS Big Sur (11.2) when I execute on terminal npm run serve. It's related to the file specific to macOS site/markdown/.DS_Store.

$ npm run serve

> markdownpedia@1.0.0 serve
> node server.js

    Now listening on port 8000
    Go to http://localhost:8000
error: Command failed: node index.js
node:internal/fs/utils:323
    throw err;
    ^

Error: ENOTDIR: not a directory, scandir 'site/markdown/.DS_Store'
    at Object.readdirSync (node:fs:1058:3)
    at getfiles (./markdownpedia/index.js:24:20)
    at getfiles (./markdownpedia/index.js:31:13)
    at Object.<anonymous> (./markdownpedia/index.js:22:1)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
    at node:internal/main/run_main_module:17:47 {
  errno: -20,
  syscall: 'scandir',
  code: 'ENOTDIR',
  path: 'site/markdown/.DS_Store'
}

error: Command failed: npm run convert
node:internal/fs/utils:323
    throw err;
    ^

Error: ENOTDIR: not a directory, scandir 'site/markdown/.DS_Store'
    at Object.readdirSync (node:fs:1058:3)
    at getfiles (./markdownpedia/index.js:24:20)
    at getfiles (./markdownpedia/index.js:31:13)
    at Object.<anonymous> (./markdownpedia/index.js:22:1)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
    at node:internal/main/run_main_module:17:47 {
  errno: -20,
  syscall: 'scandir',
  code: 'ENOTDIR',
  path: 'site/markdown/.DS_Store'
}
mamamia5x commented 3 years ago

The .DS_Store file stores the settings for folders on Mac. I don't know why this happens, but I do have an idea. The script itself goes through all the files in the directory when you run "npm run convert". A possible solution would be to have the script ignore anything that has to do with .DS_Store

That'll probably look something like (on line 23):

function getfiles(dir) {
    if (dir != ".DS_Store"){
        var files = fs.readdirSync(dir);
        var i = 0;
        while (i < files.length) {
            var now = getSecondPart(files[i]);
            if (now == 'md') {
                convert(files[i], dir);
            } else {
                getfiles(dir + '/' + files[i]);
            }
            i++;
        }
    }
}

This script just ignores anything to do with .DS_Store. If you can please try replacing the function at line 23 in index.js with the one provided, and tell me if that works. If it does, I'll update the script.

mamamia5x commented 3 years ago

No wait, that script won't work. The if statement would be in the while loop.

phv4ng commented 3 years ago

Hello,

I tried with the if statement in the while loop, and it doesn't work. The command find site/markdown -name .DS_Store -exec rm {} \; can fix the problem; it's delete .DS_store files in site/markdown.

I also got the same issue and it worked.

mamamia5x commented 3 years ago

Thanks, this way seems to tackle the issue head-on. @Marie-P tell me if it doesn't work.

Marie-P commented 3 years ago

Yes it's seems to work :ok_hand: thank you.