From fd606c55cff3ce275365fe84e370bf22a122ad39 Mon Sep 17 00:00:00 2001 From: Adam Cowley Date: Tue, 2 Dec 2025 15:24:52 +0000 Subject: [PATCH] fix(app-typescript): add expected output and troubleshooting to writing-data lesson --- .../lessons/5-c-writing-data/lesson.adoc | 66 ++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/asciidoc/courses/app-typescript/modules/1-driver/lessons/5-c-writing-data/lesson.adoc b/asciidoc/courses/app-typescript/modules/1-driver/lessons/5-c-writing-data/lesson.adoc index 8f2408dad..68d5bf58b 100644 --- a/asciidoc/courses/app-typescript/modules/1-driver/lessons/5-c-writing-data/lesson.adoc +++ b/asciidoc/courses/app-typescript/modules/1-driver/lessons/5-c-writing-data/lesson.adoc @@ -49,7 +49,20 @@ Run the file using `ts-node` to view the result: ts-node {lab-file} ---- -You can check the result in the Neo4j Browser by running the following query: +If successful, you should see output similar to the following (with your name instead of "Your Name"): + +.Expected Output +[source,json,role=nocopy] +---- +{ + identity: Integer { low: 12345, high: 0 }, + labels: [ 'Person' ], + properties: { name: 'Your Name' }, + elementId: '4:abc123:12345' +} +---- + +You can also verify the result in the Neo4j Browser by running the following query: [source, cypher] ---- @@ -57,11 +70,62 @@ MATCH (m:Movie {title: "Matrix, The"})<-[a:ACTED_IN]-(p:Person) RETURN m, a, p ---- +You should see your `Person` node connected to _The Matrix_ movie. + + include::questions/verify.adoc[leveloffset=+1] + +== Troubleshooting + +.ts-node: command not found +[%collapsible] +==== +If you receive a `ts-node: command not found` error, you can either: + +1. Install `ts-node` globally: ++ +[source,sh] +---- +npm install -g ts-node +---- + +2. Or run via npx: ++ +[source,sh,subs=attributes+] +---- +npx ts-node {lab-file} +---- +==== + +.Cannot use import statement outside a module +[%collapsible] +==== +This error occurs when Node.js tries to run TypeScript/ES modules as CommonJS. +Ensure your `tsconfig.json` has the correct module settings, or run with: + +[source,sh,subs=attributes+] +---- +npx ts-node --esm {lab-file} +---- +==== + +.Verification fails but code works +[%collapsible] +==== +If your code runs successfully and creates the node (you can see it in Neo4j Browser) but the verification fails: + +1. Ensure you are using the sandbox provided by GraphAcademy (not a local database) +2. Check that the Person node was created with an `ACTED_IN` relationship to the movie titled "Matrix, The" +3. Try refreshing the page and clicking Verify again +==== + + [.summary] == Lesson Summary In this challenge, you used your knowledge to create a driver instance and run a Cypher statement. Next, we will look at the Neo4j Type System and some of the considerations that you need to make when working with values coming from Neo4j in your TypeScript application. + +// @last-fix 2025-12-02