How do you fix "ReferenceError: primordials is not defined"?

← Ionic answers

An old tool, usually gulp 3 with an outdated graceful-fs, is running on a Node.js version newer than it supports. Upgrade gulp and the dependencies, or switch to an older Node.js with nvm.

Newer Node.js versions removed internals that old releases of graceful-fs relied on. Build tools that bundle that old version fail at startup with this error, which is common in older Ionic and Cordova projects.

  • Quick fix: use a Node.js version that the project was built for, for example nvm install 10 && nvm use 10.
  • Real fix: upgrade gulp to 4 or later (or move to the framework's current build tooling) and update the Ionic CLI.
  • If the culprit is a transitive dependency, check with npm ls graceful-fs and update the package that pulls in the old version, or use an overrides entry to force graceful-fs to 4.2 or later.
npm ls graceful-fs
nvm use 10
npm install gulp@4 --save-dev

Pin the Node.js version in .nvmrc or engines so the team and CI use the same one.

Related questions

Start debugging smarter today

Try Bugsee for free — no commitments, no hidden fees.

Free sign upLive demoNo credit card required