Skip to content

Error when running outside of top folder #2

@johanbook

Description

@johanbook

I am using Prettier for formatting in Vim (via Ale) and get the following error

Cart.js[error] Cart.js: Error: ENOENT: no such file or directory, scandir './node_modules'
[error]     at readdirSync (fs.js:981:3)
[error]     at _default (/home/pong/ui/node_modules/import-sort-style-react/lib/index.js:26:39)
[error]     at /home/pong/ui/node_modules/import-sort/lib/index.js:220:16
[error]     at sortImports (/home/pong/ui/node_modules/import-sort/lib/index.js:24:58)
[error]     at importSort (/home/pong/ui/node_modules/import-sort/lib/index.js:19:12)
[error]     at organizeImports (/home/pong/ui/node_modules/prettier-plugin-import-sort/src/index.js:51:22)
[error]     at Object.preprocess (/home/pong/ui/node_modules/prettier-plugin-import-sort/src/index.js:71:14)
[error]     at Object.parse (/home/pong/ui/node_modules/prettier/index.js:13560:21)
[error]     at coreFormat (/home/pong/ui/node_modules/prettier/index.js:14841:25)
[error]     at format (/home/pong/ui/node_modules/prettier/index.js:15063:14)

which is caused by the line

const modules = readdirSync('./node_modules');

since it is run from outside the top folder. Would it be possible to either quit without error or resolve the path some other way?

Otherwise I think this package is amazing!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions