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: Invalid layout specified. #49

Closed
truetamtam opened this issue Jul 11, 2017 · 6 comments
Closed

Error: Invalid layout specified. #49

truetamtam opened this issue Jul 11, 2017 · 6 comments

Comments

@truetamtam
Copy link

  • win10
  • git-bash
  • yarn

Installed it. Launched example from your docs.
Result - "Error: Invalid layout specified.".

@neogeek
Copy link
Member

neogeek commented Jul 12, 2017

Hmm, that is weird. I'll look into this. Managed to get tests to run and pass on Windows via Appveyor, but I'm guessing I've missed something.

@poupryc
Copy link

poupryc commented Aug 20, 2017

Same issue here on Bash subsystem for Windows

@neogeek
Copy link
Member

neogeek commented Aug 24, 2017

Sorry this is been a long-standing issue. Getting access to a PC tomorrow to diagnose the problem.

@SalathielGenese
Copy link

I think I got some hint - #61 (comment)

@jasonk
Copy link

jasonk commented Dec 28, 2019

FWIW a couple of years later.. I got this same error on a Mac, and the problem (at least in my case) was that the findPackagePath function in loaders.js uses it's own home-grown search algorithm to find where a node module is installed, and that algorithm only looks at two possible directories (the node_modules directory that doxdox was installed into, and the node_modules directory in your current working directory, if there was one) which leaves a lot of possibilities for where the packages may have been installed that they won't be found. I was trying to use it in a monorepo and it wasn't finding plugins.

I'm not entirely sure why these loadPlugin and loadParser functions are going to so much trouble to return a promise when that promise is ultimately resolved by a call to require (which is synchronous anyway), but my recommendation would be to reduce those functions down to something like this (which assumes that the handlebars plugin will provide an appropriate error if the file isn't found or isn't a file):

const loadPlugin = config => new Promise((resolve, reject) => {
  if ( config.layout.match(HANDLEBARS_PATTERN) ) {
    try {
      const pkg = require( 'doxdox-plugin-handlebars' );
      if ( pkg ) return resolve( pkg );
    } catch ( err ) {
      return reject( new Error('Invalid layout specified.') );
    }
  }
  if ( config.layout.match(JAVASCRIPT_PATTERN) ) {
    const pkg = require( path.resolve( config.layout ) );
    if ( pkg ) return resolve( pkg );
  }
  try {
    const pkg = require( `doxdox-plugin-${config.layout}` );
    if ( pkg ) return resolve( pkg );
    return reject( new Error('Invalid layout specified.') );
  } catch ( err ) {
    return reject( new Error('Invalid layout specified.') );
  }
} );

@neogeek
Copy link
Member

neogeek commented Feb 2, 2022

Window support has been improved in version v4.0.0-preview.2 and this should no longer be an issue. Feel free to re-open if the issue persists.

@neogeek neogeek closed this as completed Feb 2, 2022
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

No branches or pull requests

5 participants