DataTalksClub / DataTalksClub/faq
[FAQ]npm install crashes with "Cannot read properties of null (reading 'edgesOut')" when setting up the Homework 2 frontend
Nobody has claimed this yet.
- 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:
-
Pin vitest to the major the course reference app uses. The module's reference repository (
alexeygrigorev/interview-canvas-share) pins"vitest": "^4.1.10"infrontend/package.json:npm install -D "vitest@^4.1.0" jsdom @testing-library/react @testing-library/domQuote the range so your shell does not eat the caret.
-
If a
package-lock.jsonalready exists, usenpm ci, notnpm install.ciinstalls exactly the locked tree and never enters the resolution path that crashes:rm -rf node_modules && npm ci -
If you truly need vitest 5, upgrade npm itself (
npm install -g npm@latest), deletenode_modulesand 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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