dendronhq / dendron

The personal knowledge management (PKM) tool that grows as you do!
https://wiki.dendron.so
Apache License 2.0
6.7k stars 254 forks source link

npm run build returns `TypeError: Cannot read properties of undefined (reading 'id')` #3813

Open yviansu opened 1 year ago

yviansu commented 1 year ago

Please select the area your bug applies to. (Multiple selections are Possible. You can leave blank if you're not sure.)

Describe the bug

I want to start a local server, however, when running npx dendron publish build, every thing is fine, but when I built HTML for my notes using cd .next && npm run build, an error occurs:

> Build error occurred
TypeError: Cannot read properties of undefined (reading 'id')
    at /home/syh/Documents/Dendron/Work/.next/.next/server/chunks/774.js:151:68
    at Array.filter (<anonymous>)
    at getNotePaths (/home/syh/Documents/Dendron/Work/.next/.next/server/chunks/774.js:151:38)
    at buildStaticPaths (/home/syh/Documents/Dendron/Work/.next/node_modules/next/dist/build/utils.js:497:37)
    at /home/syh/Documents/Dendron/Work/.next/node_modules/next/dist/build/utils.js:640:125
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Span.traceAsyncFn (/home/syh/Documents/Dendron/Work/.next/node_modules/next/dist/trace/trace.js:75:20) {
  type: 'TypeError'
}

To Reproduce

Steps to reproduce the behavior:

I followed the (tutorial)[https://wiki.dendron.so/notes/svoot2ea4v5imu6rdrwuwmu/]

  1. Run 'npx dendron publish build'
  2. Run cd .next && npm run build
  3. See error

Expected behavior

I expect no error, and start a local server on localhost:3000 successfully.

Screenshots

image

Desktop (please complete the following information)

Additional context

Nothing.

Dendron Log file

logs.txt

yviansu commented 1 year ago

What's more, I have another question: Can notes from a same dendron workspace be created both on the window platform and the linux platform?

I initialized a dendron workspace in my linux server, so I can create new notes in my linux desktop vscode. However, when I connect the server in windows through vscode ssh, I can't create new notes (error while running command: Cannot read properties of undefined (reading 'map') occurs).

I push the dendron workspace into a git repo, so I can both create new notes in my local linux and create new notes in my local windows, and do version control through git. Could this be the cause of the error TypeError: Cannot read properties of undefined (reading 'id')?

hikchoi commented 1 year ago

Hey @yviansu, looks like the version of nextjs-template is pretty old on your screenshot. Can you update dendron-cli to the latest version and try it out again?

yviansu commented 1 year ago

Hi @hikchoi

I have updated dendron-cli, however, the same error occurs when I run the command cd .next && npm run build image

What's more, when I run the command npm exec dendron publish dev, the server can start on 0.0.0.0:3000, but when I reach the web, it will report error too. image

I think there is something wrong with id, could this be the cause?

I push the dendron workspace into a git repo, so I can both create new notes in my local linux and create new notes in my local windows, and do version control through git. Could this be the cause of the error TypeError: Cannot read properties of undefined (reading 'id')?

hikchoi commented 1 year ago

@yviansu hey, thanks for the quick follow-up.

Could you also make sure that the dendron version (in VSCode) is up to date?

After that, remove the .next directory completely and try running a fresh npx dendron publish init.

Let me know how that goes

yviansu commented 1 year ago

@hikchoi Thanks for your reply.

My dendron version is v0.118.0, which is last updated in 11/23/2022.

I have removed the .next directory, and run npx dendron publish init as you suggested, a new .next directory is generated. image

However, when I run npm exec dendron publish dev, the same error occured. image

When I run cd .next && npm run build after command npx dendron publish build , the same error occured too. image

hikchoi commented 1 year ago

any particular reason you are using npm exec to run dendron publish dev?

Could you also share the content of dendron.yml if it doesn't contain any sensitive information?

Also, what do you see in the terminal when you hit the error page during dendron publish dev? Do you see any logs along the line of no note found?

hikchoi commented 1 year ago

tagging @namjul for visibility

yviansu commented 1 year ago

Hi, @hikchoi

I followed the publish quickstart note to publish my website. I want to launch a development server so that others can see my notes, so I choose the command npx dendron publish dev. (I might run command npx exec dendron publish dev before, but these two commands cause the same error TypeError: Cannot read properties of undefined (reading 'id'))

I have not seen logs related to no note found, however, when I launch my website localhost:3000, the log will show wait - compiling /_error (client and server).... image

My dendron.yml file is: dendron_yml.txt