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

discoverNpmPlugins function breaks the generation #1102

Closed
1 task done
ethikz opened this issue Sep 26, 2019 · 4 comments
Closed
1 task done

discoverNpmPlugins function breaks the generation #1102

ethikz opened this issue Sep 26, 2019 · 4 comments
Labels
bug Functionality does not match expectation

Comments

@ethikz
Copy link

ethikz commented Sep 26, 2019

Expected Behavior

I expect it to resolve all files/paths and build documentation

Actual Behavior

It fails to build the documentation and crashes.

The error showing in terminal is:

> angular-tour-of-heroes@1.0.0 docs ~/development/angular-tour-of-heroes
> typedoc -- --options typedoc.json --exclude '**/*.spec.ts' ./src/

fs.js:114
    throw err;
    ^

Error: ENOTDIR: not a directory, scandir '~/node_modules/@babel-code-frame-7.0.0-beta.44.tgz'
    at Object.readdirSync (fs.js:790:3)
    at FS.readdirSync.forEach (~/development/angular-tour-of-heroes/node_modules/typedoc/dist/lib/utils/plugins.js:72:24)
    at Array.forEach (<anonymous>)
    at discoverModules (~/development/angular-tour-of-heroes/node_modules/typedoc/dist/lib/utils/plugins.js:69:38)
    at discover (~/development/angular-tour-of-heroes/node_modules/typedoc/dist/lib/utils/plugins.js:61:21)
    at PluginHost.discoverNpmPlugins (~/development/angular-tour-of-heroes/node_modules/typedoc/dist/lib/utils/plugins.js:54:9)
    at PluginHost.load (~/development/angular-tour-of-heroes/node_modules/typedoc/dist/lib/utils/plugins.js:16:46)
    at CliApplication.bootstrap (~/development/angular-tour-of-heroes/node_modules/typedoc/dist/lib/application.js:42:22)
    at CliApplication.bootstrap (~/development/angular-tour-of-heroes/node_modules/typedoc/dist/lib/cli.js:24:30)
    at new Application (~/development/angular-tour-of-heroes/node_modules/typedoc/dist/lib/application.js:31:14)

After some debugging, the breaking happens with this specific line path = Path.resolve(Path.join(previous, '..'));

It seems to get all node_modules in the local directory then it traverses up every directory until it gets to my home directory node_modules and then it breaks looking for that module for whatever reason.

When I comment that line out completely it works fine. Being that I am not 100% sure what this function does completely in the scheme of typedoc, I'm hesitant to submit a PR.

Steps to reproduce the bug

typedoc.js

module.exports = {
  out: 'docs',
  includes: '/',
  exclude: [
    '**/*.spec.ts',
    '**/node_modules/**'
  ],
  mode: 'modules',
  theme: 'default',
  ignoreCompilerErrors: 'true',
  target: 'ES5',
  module: 'commonjs'
};

package.json

"scripts": {
  [...]
  "docs": "npm run typedoc -- --options typedoc.js ./src/",
  "typedoc": "typedoc",
}

Environment

  • Typedoc version: 0.15.0
  • Node.js version: 10.16.0
  • OS: OSX 10.14.6
@ethikz ethikz added the bug Functionality does not match expectation label Sep 26, 2019
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Oct 12, 2019

Introduced with #736. We assumed that files under node_modules that start with @ are folders used for npm's scoped packages, but this clearly isn't a safe assumption as you've found. Adding a check to ensure that it is a directory before trying to check its children should fix the issue.

That said, I recall some discussion somewhere (either in gitter or an issue, I can't seem to find it) about removing automatic plugin discovery since it makes load order considerably harder to follow and may include plugins you don't expect if one of your dependencies had them in their dependencies instead of devDependencies for some reason.

@ethikz
Copy link
Author

ethikz commented Dec 12, 2019

@Gerrit0 Is there any movement or update on this?

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Dec 13, 2019

I haven't had the time to get to it yet, I should be able to take a look this weekend

@ethikz
Copy link
Author

ethikz commented Dec 13, 2019

@Gerrit0 No problem! I just didn't want this to get lost in the ether. I have solved the solution for now by just removing the global node_modules folder in the user directory. Not sure what other issues this can and/or will pose.

Thanks for your response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

2 participants