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

Error: ENOTDIR: not a directory when using "layouts/Layout.vue" as entry file #1563

Closed
1 task done
ocavue opened this issue Apr 25, 2019 · 0 comments · Fixed by #1564
Closed
1 task done

Error: ENOTDIR: not a directory when using "layouts/Layout.vue" as entry file #1563

ocavue opened this issue Apr 25, 2019 · 0 comments · Fixed by #1564

Comments

@ocavue
Copy link
Contributor

ocavue commented Apr 25, 2019

  • I confirm that this is an issue rather than a question.

Bug report

Version

vuepress: 1.0.0-alpha.47

Steps to reproduce

What is expected?

When I set the "main" field to layouts/Layout.vue in package.json as what the docs
tell me to do, I can build my package successfully.

What is actually happening?

function normalizeThemePath (resolved) {
const { entry, name, fromDep } = resolved
if (fromDep) {
const packageRoot = require.resolve(`${name}/package.json`)
const { main } = require(packageRoot)
if (main.endsWith('.vue')) {
// For those cases that "main" field is set to an non-index file
// e.g. `layouts/Layout.vue`
return packageRoot
} else {
// For those cases that "index.js" is not at package root
// e.g. `lib/index.js` (#1362)
return parse(require.resolve(name)).dir
}
} else if (entry.endsWith('.js') || entry.endsWith('.vue')) {
return parse(entry).dir
} else {
return entry
}
}

function normalizeThemePath return 'xxxx/package.json' because fromDep===true and main==="layouts/Layout.vue" in my case and casue the error below.

Error: ENOTDIR: not a directory, scandir '/Users/ocavue/code/github/vuepress-theme-blogue/package.json'
    at Object.readdirSync (fs.js:806:3)
    at readdirSync (/Users/ocavue/code/github/vuepress-theme-blogue/example/node_modules/@vuepress/core/lib/node/theme-api/index.js:2:53)
    at dirs.map.layoutDir (/Users/ocavue/code/github/vuepress-theme-blogue/example/node_modules/@vuepress/core/lib/node/theme-api/index.js:113:18)
    at Array.map (<anonymous>)
    at resolveSFCs (/Users/ocavue/code/github/vuepress-theme-blogue/example/node_modules/@vuepress/core/lib/node/theme-api/index.js:112:15)
    at ThemeAPI.getLayoutComponentMap (/Users/ocavue/code/github/vuepress-theme-blogue/example/node_modules/@vuepress/core/lib/node/theme-api/index.js:74:32)
    at ThemeAPI.init (/Users/ocavue/code/github/vuepress-theme-blogue/example/node_modules/@vuepress/core/lib/node/theme-api/index.js:34:36)
    at new ThemeAPI (/Users/ocavue/code/github/vuepress-theme-blogue/example/node_modules/@vuepress/core/lib/node/theme-api/index.js:16:10)
    at loadTheme (/Users/ocavue/code/github/vuepress-theme-blogue/example/node_modules/@vuepress/core/lib/node/loadTheme.js:53:10)
    at App.process (/Users/ocavue/code/github/vuepress-theme-blogue/example/node_modules/@vuepress/core/lib/node/App.js:100:21)
    at dev (/Users/ocavue/code/github/vuepress-theme-blogue/example/node_modules/@vuepress/core/lib/index.js:14:13)
    at args (/Users/ocavue/code/github/vuepress-theme-blogue/example/node_modules/vuepress/lib/util.js:35:12)
    at CAC.cli.command.option.option.option.option.option.option.option.option.option.action (/Users/ocavue/code/github/vuepress-theme-blogue/example/node_modules/vuepress/lib/registerCoreCommands.js:35:23)
    at CAC.runMatchedCommand (/Users/ocavue/code/github/vuepress-theme-blogue/example/node_modules/cac/dist/index.js:702:38)
    at CAC.parse (/Users/ocavue/code/github/vuepress-theme-blogue/example/node_modules/cac/dist/index.js:622:18)
    at CLI (/Users/ocavue/code/github/vuepress-theme-blogue/example/node_modules/vuepress/lib/util.js:23:7)

If I change return packageRoot into return parse(require.resolve(name)).dir, this issue will not occur.

Other relevant information

  • Your OS: macOS 10.13.6
  • Node.js version: v11.14.0
  • Browser version: N/A
  • Is this a global or local install? local
  • Which package manager did you use for the install? yarn
  • Does this issue occur when all plugins are disabled? yes
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

Successfully merging a pull request may close this issue.

1 participant