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" 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.
-
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
-
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
Course
ai-dev-tools-zoomcamp
Question
While setting up the frontend for Homework 2 (module 02-development),
npm install— ornpm i -D vitest …— dies with: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— ornpm i -D vitest …— dies with: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 ciIf 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) andnpm test/npx vitest run.Prevention: commit your
package-lock.jsonwith the frontend — the module deliverables expect reproducible installs, and anyone cloning your repo (including the grader) then usesnpm ciand never touches the buggy resolver.Checklist