Skip to content

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

Description

@yazdanparasthesam

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions