Docz: When no name is specified in mdx file, it throws Cannot read property 'name' of undefined

Created on 19 Jun 2018  Â·  12Comments  Â·  Source: doczjs/docz

Bug Report

To Reproduce

Create an MDX file with no name specified.
It will generate the error:

$ docz dev
TypeError: Cannot read property 'name' of undefined
    at new Entry (.../frontend/node_modules/docz-core/dist/index.js:1:5189)
    at Promise.all.s.filter.map (.../frontend/node_modules/docz-core/dist/index.js:1:7654)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:746:11)
    at startup (internal/bootstrap/node.js:238:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:572:3)

Expected behavior

Provide a helpful error message that $path/to/file.mdx does not contain a name.

It probably occurs at this line but couldn't find out how to run docz without using the dist version to validate:
https://github.com/pedronauck/docz/blob/master/packages/docz-core/src/Entry.ts#L98

bug

All 12 comments

@pedronauck I would like to take this up.The solution I am thinking here is throwing an error with the message of $path/to/file.mdx does not contain a name.

@pedronauck While trying to do a yarn commit I am facing this error

stderr: 'ERROR: Task not found: "/Users/viveknayyar/vivek/docz/packages/docz-core/src/Entry.ts"
✖ "yarn packages:fix" found some errors. Please fix them and try committing again.
$ lerna run fix /Users/viveknayyar/vivek/docz/packages/docz-core/src/Entry.ts

@pedronauck Can you help here in this yarn commit issue that I am facing.

Do you trying to build packages to make some pull request @vivek12345? Which version of node you're using?

Node version is v9.0.0 @pedronauck
and this is the change that I am trying to commit

if (!parsed) {
   throw new Error(`${filepath} does not contain a name`)
}

@pedronauck any suggestions as to what I can do to commit my change and make a PR for the same.

what commands are you using to build and then commit @vivek12345 ?

@marceloavf I did those above mentioned changes inside docz-core/src/Entry.ts
After that did a yarn build in docz-core folder.

Finally git add and yarn commit

I see this error all the time

ERROR: Task not found: "/Users/viveknayyar/vivek/docz/packages/docz-core/src/Entry.ts"

@vivek12345 Seems to be some issue with this path.

For now, try to commit normally with git commit -m "fix(docz-core): throw error in no parsed file" and see if it works.

If you could please say your Operational System too, should help us find what is happening.
Thank you

Sure I will try as you suggested.
I am working from my MacBook Pro macOs High Sierra

Thank you @marceloavf for your help. I have raised a PR for the same.

🎉  Fixed and released in the new v0.4.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

capaj picture capaj  Â·  3Comments

hayk94 picture hayk94  Â·  3Comments

tsnolan23 picture tsnolan23  Â·  3Comments

danburzo picture danburzo  Â·  3Comments

bichotll picture bichotll  Â·  3Comments