DataTalksClub / DataTalksClub/faq

[FAQ]npm install crashes with "Cannot read properties of null (reading 'edgesOut')" when setting up the Homework 2 frontend

Open Beginner friendly
#404 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

faq-proposal
Dominant language
Python
Stars
7
Forks
19
Avg merge
3d 20h
Merged PRs (30d)
9

Description

Course

ai-dev-tools-zoomcamp

Question

While setting up the frontend for Homework 2 (module 02-development), npm install — or npm i -D vitest … — dies with:

npm error TypeError: Cannot read properties of null (reading 'edgesOut')

Nothing installs, the stack trace is inside npm's arborist, and retrying gives the same crash. My code compiles in my head fine, so what is actually wrong and how do I get a working test setup?

Answer

While setting up the frontend for Homework 2 (module 02-development), npm install — or npm i -D vitest … — dies with:

npm error TypeError: Cannot read properties of null (reading 'edgesOut')

Nothing installs, the stack trace is inside npm's arborist, and retrying gives the same crash. My code compiles in my head fine, so what is actually wrong and how do I get a working test setup?

Answer

This is a crash in npm's dependency resolver (arborist), not in your project. It reproduces on npm 10.x (observed on 10.8.2 and 10.9.8, Node 20 and Node 22) when npm resolves the peer-dependency set of vitest@5 — i.e. when vitest is added unpinned, or re-resolved without a lockfile.

Fixes, in order of preference:

  1. Pin vitest to the major the course reference app uses. The module's reference repository (alexeygrigorev/interview-canvas-share) pins "vitest": "^4.1.10" in frontend/package.json:

    npm install -D "vitest@^4.1.0" jsdom @testing-library/react @testing-library/dom
    

    Quote the range so your shell does not eat the caret.

  2. If a package-lock.json already exists, use npm ci, not npm install. ci installs exactly the locked tree and never enters the resolution path that crashes:

    rm -rf node_modules && npm ci
    
  3. If you truly need vitest 5, upgrade npm itself (npm install -g npm@latest), delete node_modules and the lockfile, and retry. For this homework, matching the reference app's 4.x is the safer choice.

Verify with npm ls vitest (should print 4.1.x) and npm test / npx vitest run.

Prevention: commit your package-lock.json with the frontend — the module deliverables expect reproducible installs, and anyone cloning your repo (including the grader) then uses npm ci and never touches the buggy resolver.

Checklist
  • I have searched existing FAQs and this question is not already answered
  • The answer provides accurate, helpful information
  • I have included any relevant code examples or links

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the FAQ issue text and the referenced frontend/package.json and package-lock.json files. Verify the npm 10.x failure with the listed vitest versions, then ensure the FAQ clearly documents the working install and verification commands; check completion with npm ls vitest and npm test or npx vitest run.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.